package com.dragon.mmochat.service;

import java.awt.Color;
import java.io.File;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.dao.EmptyResultDataAccessException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;

import com.dragon.mmochat.MmochatConstant;
import com.dragon.mmochat.MmochatMain;
import com.dragon.mmochat.message.MmochatBackToOldServer;
import com.dragon.mmochat.message.Mmochat_12_15S;
import com.dragon.mmochat.message.Mmochat_12_23S;
import com.dragon.mmochat.message.Mmochat_13_4S;
import com.dragon.mmochat.message.Mmochat_14_11S;
import com.dragon.mmochat.message.Mmochat_15_12S;
import com.dragon.mmochat.message.Mmochat_17_5S;
import com.dragon.mmochat.message.Mmochat_1_1S;
import com.dragon.mmochat.message.Mmochat_1_7S;
import com.dragon.mmochat.message.Mmochat_4_11S;
import com.dragon.mmochat.message.Mmochat_4_12S;
import com.dragon.mmochat.message.Mmochat_4_14S;
import com.dragon.mmochat.message.Mmochat_5_10S;
import com.dragon.mmochat.message.Mmochat_5_1S;
import com.dragon.mmochat.message.Mmochat_5_31S;
import com.dragon.mmochat.message.Mmochat_9_10C;
import com.dragon.mmochat.message.Mmochat_9_11S;
import com.dragon.mmochat.message.Mmochat_9_12C;
import com.dragon.mmochat.message.Mmochat_9_13C;
import com.dragon.mmochat.message.Mmochat_9_14C;
import com.dragon.mmochat.message.Mmochat_9_15C;
import com.dragon.mmochat.message.Mmochat_9_16C;
import com.dragon.mmochat.message.Mmochat_9_17C;
import com.dragon.mmochat.message.Mmochat_9_18C;
import com.dragon.mmochat.message.Mmochat_9_19C;
import com.dragon.mmochat.message.Mmochat_9_1C;
import com.dragon.mmochat.message.Mmochat_9_20C;
import com.dragon.mmochat.message.Mmochat_9_21C;
import com.dragon.mmochat.message.Mmochat_9_22C;
import com.dragon.mmochat.message.Mmochat_9_23C;
import com.dragon.mmochat.message.Mmochat_9_24C;
import com.dragon.mmochat.message.Mmochat_9_25C;
import com.dragon.mmochat.message.Mmochat_9_26C;
import com.dragon.mmochat.message.Mmochat_9_27C;
import com.dragon.mmochat.message.Mmochat_9_28C;
import com.dragon.mmochat.message.Mmochat_9_29C;
import com.dragon.mmochat.message.Mmochat_9_30C;
import com.dragon.mmochat.message.Mmochat_9_31C;
import com.dragon.mmochat.message.Mmochat_9_32C;
import com.dragon.mmochat.message.Mmochat_9_33C;
import com.dragon.mmochat.message.Mmochat_9_34C;
import com.dragon.mmochat.message.Mmochat_9_35C;
import com.dragon.mmochat.message.Mmochat_9_36C;
import com.dragon.mmochat.message.Mmochat_9_37C;
import com.dragon.mmochat.message.Mmochat_9_38C;
import com.dragon.mmochat.message.Mmochat_9_39C;
import com.dragon.mmochat.message.Mmochat_9_40C;
import com.dragon.mmochat.message.Mmochat_9_41C;
import com.dragon.mmochat.message.Mmochat_9_42C;
import com.dragon.mmochat.message.Mmochat_9_43C;
import com.dragon.mmochat.message.Mmochat_9_44C;
import com.dragon.mmochat.message.Mmochat_9_45C;
import com.dragon.mmochat.message.Mmochat_9_46C;
import com.dragon.mmochat.message.Mmochat_9_47C;
import com.dragon.mmochat.message.Mmochat_9_48C;
import com.dragon.mmochat.message.Mmochat_9_49C;
import com.dragon.mmochat.message.Mmochat_9_50C;
import com.dragon.mmochat.message.Mmochat_9_51C;
import com.dragon.mmochat.message.Mmochat_9_52C;
import com.dragon.mmochat.message.Mmochat_9_53C;
import com.dragon.mmochat.message.Mmochat_9_54C;
import com.dragon.mmochat.message.Mmochat_9_61C;
import com.dragon.mmochat.message.Mmochat_9_62C;
import com.dragon.mmochat.message.Mmochat_9_63C;
import com.dragon.mmochat.message.Mmochat_9_64C;
import com.dragon.mmochat.message.Mmochat_9_65C;
import com.dragon.mmochat.message.Mmochat_9_66C;
import com.dragon.mmochat.message.Mmochat_9_6C;
import com.dragon.mmochat.message.Mmochat_9_7C;
import com.dragon.mmochat.message.Mmochat_9_8C;
import com.dragon.mmochat.message.Mmochat_9_9C;
import com.dragon.mmochat.message.Mmochat_EnterMultiServerLeiTai;
import com.dragon.mmochat.message.Mmochat_EnterOtherServerMap;
import com.dragon.mmochat.message.Mmochat_SetMixWuDaoWordsToServerList;
import com.dragon.mmochat.model.MmochatChenHao;
import com.dragon.mmochat.model.MmochatDailyActivity;
import com.dragon.mmochat.model.MmochatEventLog;
import com.dragon.mmochat.model.MmochatRoleRankInfo;
import com.dragon.mmochat.model.MmochatTeam;
import com.dragon.mmochat.model.MmochatWuDaoWinWords;
import com.dragon.mmochat.model.activity.MmochatSystemState;
import com.dragon.mmochat.model.attackMode.MmochatAttackModeOfNormal;
import com.dragon.mmochat.model.battle.MmochatBattle;
import com.dragon.mmochat.model.bet.MmochatBet;
import com.dragon.mmochat.model.enumType.MmochatBattleModelType;
import com.dragon.mmochat.model.enumType.MmochatBattleOrderType;
import com.dragon.mmochat.model.enumType.MmochatBetType;
import com.dragon.mmochat.model.enumType.MmochatBigMoneyCostType;
import com.dragon.mmochat.model.enumType.MmochatBigMoneyEarnType;
import com.dragon.mmochat.model.enumType.MmochatBossLevelType;
import com.dragon.mmochat.model.enumType.MmochatChenHaoType;
import com.dragon.mmochat.model.enumType.MmochatDailyActivityType;
import com.dragon.mmochat.model.enumType.MmochatDrugType;
import com.dragon.mmochat.model.enumType.MmochatEquipAttributeQualityType;
import com.dragon.mmochat.model.enumType.MmochatEquipAttributeType;
import com.dragon.mmochat.model.enumType.MmochatEquipPlaceType;
import com.dragon.mmochat.model.enumType.MmochatEquipQualityType;
import com.dragon.mmochat.model.enumType.MmochatEquipType;
import com.dragon.mmochat.model.enumType.MmochatEventType;
import com.dragon.mmochat.model.enumType.MmochatFamilyType;
import com.dragon.mmochat.model.enumType.MmochatFuBenType;
import com.dragon.mmochat.model.enumType.MmochatGangLevelType;
import com.dragon.mmochat.model.enumType.MmochatGangMemberType;
import com.dragon.mmochat.model.enumType.MmochatGangSkillType;
import com.dragon.mmochat.model.enumType.MmochatLifeSkillType;
import com.dragon.mmochat.model.enumType.MmochatMapHintType;
import com.dragon.mmochat.model.enumType.MmochatMaterialType;
import com.dragon.mmochat.model.enumType.MmochatNpcFaceType;
import com.dragon.mmochat.model.enumType.MmochatNpcItemType;
import com.dragon.mmochat.model.enumType.MmochatNpcState;
import com.dragon.mmochat.model.enumType.MmochatObjOwnerState;
import com.dragon.mmochat.model.enumType.MmochatObjectType;
import com.dragon.mmochat.model.enumType.MmochatPetType;
import com.dragon.mmochat.model.enumType.MmochatPropType;
import com.dragon.mmochat.model.enumType.MmochatRoleAttributeType;
import com.dragon.mmochat.model.enumType.MmochatRoleBmpType;
import com.dragon.mmochat.model.enumType.MmochatRoleStateType;
import com.dragon.mmochat.model.enumType.MmochatRoleType;
import com.dragon.mmochat.model.enumType.MmochatSecondRoleType;
import com.dragon.mmochat.model.enumType.MmochatShopType;
import com.dragon.mmochat.model.enumType.MmochatSkillType;
import com.dragon.mmochat.model.enumType.MmochatSmallMoneyCostType;
import com.dragon.mmochat.model.enumType.MmochatSmallMoneyEarnType;
import com.dragon.mmochat.model.enumType.MmochatSpecialSkillType;
import com.dragon.mmochat.model.enumType.MmochatStorePwdState;
import com.dragon.mmochat.model.enumType.MmochatSuperMachineType;
import com.dragon.mmochat.model.enumType.MmochatTaskStateType;
import com.dragon.mmochat.model.enumType.MmochatTaskType;
import com.dragon.mmochat.model.enumType.MmochatTeamStateType;
import com.dragon.mmochat.model.fuBen.MmochatFuBen;
import com.dragon.mmochat.model.fuBen.MmochatGangFuBen;
import com.dragon.mmochat.model.gang.MmochatGang;
import com.dragon.mmochat.model.gang.MmochatGangMember;
import com.dragon.mmochat.model.gang.MmochatGangSkill;
import com.dragon.mmochat.model.map.MmochatMap;
import com.dragon.mmochat.model.map.MmochatMapGuider;
import com.dragon.mmochat.model.map.MmochatMapGuiderData;
import com.dragon.mmochat.model.map.MmochatMapHint;
import com.dragon.mmochat.model.map.MmochatMapTransPoint;
import com.dragon.mmochat.model.map.MmochatPoint;
import com.dragon.mmochat.model.object.MmochatCommonObject;
import com.dragon.mmochat.model.object.MmochatDrug;
import com.dragon.mmochat.model.object.MmochatEquip;
import com.dragon.mmochat.model.object.MmochatEquipAttribute;
import com.dragon.mmochat.model.object.MmochatMaterial;
import com.dragon.mmochat.model.object.MmochatPackageGrid;
import com.dragon.mmochat.model.object.MmochatProp;
import com.dragon.mmochat.model.object.MmochatPropEffect;
import com.dragon.mmochat.model.object.MmochatSuperMachine;
import com.dragon.mmochat.model.role.MmochatActivityNpc;
import com.dragon.mmochat.model.role.MmochatBossFactory;
import com.dragon.mmochat.model.role.MmochatFriend;
import com.dragon.mmochat.model.role.MmochatMonsterFactory;
import com.dragon.mmochat.model.role.MmochatNpc;
import com.dragon.mmochat.model.role.MmochatPet;
import com.dragon.mmochat.model.role.MmochatPlayer;
import com.dragon.mmochat.model.role.MmochatRankPlayer;
import com.dragon.mmochat.model.role.MmochatTempNpc;
import com.dragon.mmochat.model.scheduleJob.pkGame.activities.MmochatGangMixedPkGame;
import com.dragon.mmochat.model.scheduleJob.pkGame.activities.MmochatMultiServerWuDaoPkGame;
import com.dragon.mmochat.model.scheduleJob.pkGame.activities.MmochatNo1PkGame;
import com.dragon.mmochat.model.skill.MmochatSpecialSkill;
import com.dragon.mmochat.model.task.MmochatKillMonster;
import com.dragon.mmochat.model.task.MmochatNpcBattle;
import com.dragon.mmochat.model.task.MmochatTask;
import com.dragon.mmochat.model.task.MmochatTempTask;
import com.dragon.mmochat.util.CallLocalFuncTlv;
import com.dragon.mmochat.util.CreateMsgBoxTLVWithBmp;
import com.dragon.mmochat.util.CreateTlvWin;
import com.dragon.mmochat.util.MmochatUtil;
import com.dragon.mmochat.util.SendBigPackUtil;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.skymobi.handler.SkymobiHandler;
import com.skymobi.message.SkymobiProtocolMessage;
import com.skymobi.message.widget.AddDataTLV;
import com.skymobi.message.widget.AddEditBoxTLV;
import com.skymobi.message.widget.ClearDataTLV;
import com.skymobi.message.widget.CloseWinTLV;
import com.skymobi.message.widget.CreateEditBoxTLV;
import com.skymobi.message.widget.CreateMsgBoxTLV;
import com.skymobi.message.widget.CtrlTLVStructureRequest;
import com.skymobi.message.widget.SendDataTLV;
import com.skymobi.message.widget.ShowWaitingMsgBoxTLV;
import com.skymobi.message.widget.TLVStructure;
import com.skymobi.message.widget.WinType;
import com.skymobi.service.SkymobiService;
import com.skymobi.util.Text;

public class MmochatNpcService {
	private static Logger log = LoggerFactory
			.getLogger(MmochatNpcService.class);

	public static Map<Integer, MmochatNpc> npcs = new ConcurrentHashMap<Integer, MmochatNpc>();
	private static List<MmochatBossFactory> activityBoss = new ArrayList<MmochatBossFactory>();

	public static ScheduledExecutorService rankThread = Executors
			.newScheduledThreadPool(1);

	public static ScheduledExecutorService checkBossLifeThread = Executors
			.newScheduledThreadPool(1);

	public static ScheduledExecutorService createMapBossThread = Executors
			.newScheduledThreadPool(1);

	public static ScheduledExecutorService checkFuBenThread = Executors
			.newScheduledThreadPool(1);

	// 重要装备回收记录:改造过的、粉、绿、首饰
	// roleId-->此人丟掉的东西
	public static Map<Integer, List<MmochatCommonObject>> soldToSystemObjMap = new ConcurrentHashMap<Integer, List<MmochatCommonObject>>();

	// 等级排行
	public static List<MmochatRankPlayer> levelRank = new ArrayList<MmochatRankPlayer>();

	// 道行排行(总榜)
	public static List<MmochatRankPlayer> daoRank = new ArrayList<MmochatRankPlayer>();

	// 道行排行(等级榜):等级-->道榜
	public static Map<Integer, List<MmochatRankPlayer>> daoRankOfLevel = new ConcurrentHashMap<Integer, List<MmochatRankPlayer>>();

	// 战绩排行
	public static List<MmochatRankPlayer> zhanJiRank = new ArrayList<MmochatRankPlayer>();

	// 财富排行
	public static List<MmochatRankPlayer> moneyRank = new ArrayList<MmochatRankPlayer>();

	// 物伤排行、法伤排行、速度排行:Map<等级,Map<角色ID,角色信息>>
	public static Map<Integer, Map<Integer, MmochatRoleRankInfo>> physicalRank = new ConcurrentHashMap<Integer, Map<Integer, MmochatRoleRankInfo>>();
	public static Map<Integer, Map<Integer, MmochatRoleRankInfo>> magicRank = new ConcurrentHashMap<Integer, Map<Integer, MmochatRoleRankInfo>>();
	public static Map<Integer, Map<Integer, MmochatRoleRankInfo>> speedRank = new ConcurrentHashMap<Integer, Map<Integer, MmochatRoleRankInfo>>();

	// 名人榜:roleId->roleId
	public static Map<Integer, Integer> famousList = new ConcurrentHashMap<Integer, Integer>();

	// 活动日志(按时间先后排序)
	public static List<MmochatEventLog> eventLogList = null;

	// 双倍奖券的时间点
	public static List<String> jianQuanDoubleAwardDateList = new ArrayList<String>();

	// 门派试炼全民开放的时间点
	public static List<String> familyTrainOpenDateList = new ArrayList<String>();

	public static Object multiServerPkNpcLock = new Object();

	// 副本:ID->副本
	public static Map<Integer, MmochatFuBen> fuBens = new ConcurrentHashMap<Integer, MmochatFuBen>();

	// 帮派副本:ID->副本
	public static Map<Integer, MmochatGangFuBen> gangFuBens = new ConcurrentHashMap<Integer, MmochatGangFuBen>();

	// 熟练度训练所需元宝
	public static int[] bigMoneyForTrain = new int[] { 0, 10, 25, 45, 70, 100,
			0, 0, 0, 0, 0, 0, 0 };

	// 押镖统计:roleId-->moneyAward；方便统计总参加人数，总产出，人均收入，最高收入等数据
	public static Map<Integer, Integer> YBMap = new ConcurrentHashMap<Integer, Integer>();

	// 试道王者宣言
	public static Map<Integer, MmochatWuDaoWinWords> wuDaoWinWords = new ConcurrentHashMap<Integer, MmochatWuDaoWinWords>();

	// 跨服王者更新宣言时间:roleId-->lastTime
	public static Map<Integer, Long> mixWuDaoWordsUpdateTimes = new ConcurrentHashMap<Integer, Long>();

	//跨服王者宣言
	public static Map<Integer, MmochatWuDaoWinWords> mixWuDaoWinWords = new ConcurrentHashMap<Integer, MmochatWuDaoWinWords>();

	
	public static final String[] simplePwd = new String[] { "123456",
			"1234567", "12345678", "123456789", "111111", "222222", "333333",
			"444444", "555555", "666666", "777777", "888888", "999999",
			"000000", "1111111", "2222222", "3333333", "4444444", "5555555",
			"6666666", "7777777", "8888888", "9999999", "0000000", "11111111",
			"22222222", "33333333", "44444444", "55555555", "66666666",
			"77777777", "88888888", "99999999", "00000000", "111111111",
			"222222222", "333333333", "444444444", "555555555", "666666666",
			"777777777", "888888888", "999999999", "000000000", };

	public static void addJianQuanDoubleAwardDate(String date) {
		jianQuanDoubleAwardDateList.add(date);
	}

	public static boolean isTodayJianQuanDoubleAward() {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		String today = sdf.format(new Date());
		if (jianQuanDoubleAwardDateList.contains(today)) {
			return true;
		}
		return false;
	}

	public static void addFamilyTrainOpenDate(String date) {
		familyTrainOpenDateList.add(date);
	}

	public static boolean isFamilyTrainOpenToday() {
		// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		// String today = sdf.format(new Date());
		// if (familyTrainOpenDateList.contains(today)) {
		// return true;
		// }
		// return false;
		return true;
	}

	// private static int testCount;
	// private static Object testLock = new Object();

	@SuppressWarnings("deprecation")
	public void init() {
		if (!MmochatMain.openMergeServer) {
			try {
				// TODO:test
				// System.out.println("start======================");
				// testCount = 0;
				// for (int i = 0; i < 14; i++) {
				// new Thread(new doTest(i * 20000, (i + 1) * 20000)).start();
				// }
				// while (true) {
				// System.out.println(testCount + "");
				// Thread.sleep(2000);
				// if (testCount >= 279900) {
				// break;
				// }
				// }
				// System.out.println("end======================");
				// System.exit(0);

				if (!MmochatMain.openMergeServer) {
					// 加载所有活动日志,3个月内
					try {
						new Thread(new loadEventLog()).start();
					} catch (Exception e1) {
						e1.printStackTrace();
					}

					// 每天早上5点重新加载排行
					Date now = new Date();
					int hour = now.getHours();
					int minutes = now.getMinutes();
					int sec = now.getSeconds();
					int startTime = (int) ((60 - sec) + (60 - minutes - 1)
							* MmochatConstant.SECOND_PER_MIN + (5 - hour - 1)
							* MmochatConstant.SECOND_PER_HOUR);
					if (startTime <= 0) {
						startTime += MmochatConstant.SECOND_PER_DAY;
					}

					// 初始化即时排行
					try {
						// 物伤排行、法伤排行、速度排行:Map<等级,Map<角色ID,角色信息>>
						for (int level = 30; level < 130; level += 10) {
							physicalRank
									.put(
											level,
											new ConcurrentHashMap<Integer, MmochatRoleRankInfo>());
							magicRank
									.put(
											level,
											new ConcurrentHashMap<Integer, MmochatRoleRankInfo>());
							speedRank
									.put(
											level,
											new ConcurrentHashMap<Integer, MmochatRoleRankInfo>());
						}
					} catch (Exception e) {
						e.printStackTrace();
					}

					// 异步加载排行
					try {
						new Thread(new loadRank()).start();
					} catch (Exception e) {
						e.printStackTrace();
					}

					rankThread.scheduleAtFixedRate(new loadRank(), startTime,
							MmochatConstant.SECOND_PER_DAY, TimeUnit.SECONDS);

					checkBossLifeThread.scheduleWithFixedDelay(
							new checkBossLife(), 60, 60, TimeUnit.SECONDS);

					int startMinite = MmochatUtil.getRandomValue(40) + 10;
					createMapBossThread.scheduleWithFixedDelay(
							new createMapBoss(), startMinite, 20,
							TimeUnit.MINUTES);

					checkFuBenThread.scheduleWithFixedDelay(new checkFuBen(),
							1, 1, TimeUnit.MINUTES);

					// 加载所有活动BOSS
					activityBoss.clear();
					File root = new File("boss");
					File[] files = root.listFiles();
					if (files != null) {
						for (File file : files) {
							if (!file.isFile()) {
								continue;
							}
							DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory
									.newInstance();
							DocumentBuilder docBuilder = docBuilderFactory
									.newDocumentBuilder();
							Document doc = docBuilder.parse(file);

							// normalize text redivsentation
							doc.getDocumentElement().normalize();
							NodeList listOfTask = doc
									.getElementsByTagName("MmochatBossFactory");
							log.debug("specialNpc num = "
									+ listOfTask.getLength());

							for (int s = 0; s < listOfTask.getLength(); s++) {
								Node firstBossNode = listOfTask.item(s);
								if (firstBossNode.getNodeType() == Node.ELEMENT_NODE) {
									MmochatBossFactory boss = new MmochatBossFactory();
									activityBoss.add(boss);
									Element firstBossElement = (Element) firstBossNode;
									// 读取name
									{
										NodeList node = firstBossElement
												.getElementsByTagName("name");
										String str = node.item(0)
												.getChildNodes().item(0)
												.getNodeValue().trim();
										boss.setName(str);
									}
									// 读取bmp
									{
										NodeList node = firstBossElement
												.getElementsByTagName("bmp");
										String str = node.item(0)
												.getChildNodes().item(0)
												.getNodeValue().trim();
										boss.setBmpType(MmochatRoleBmpType
												.valueOf(str));
									}
									// 读取level
									{
										NodeList node = firstBossElement
												.getElementsByTagName("level");
										String str = node.item(0)
												.getChildNodes().item(0)
												.getNodeValue().trim();
										int num;
										try {
											num = Integer.parseInt(str);
										} catch (Exception e) {
											e.printStackTrace();
											throw new RuntimeException(
													"加载"
															+ file.getName()
															+ "时，specialNpc的level不是数字,name="
															+ boss.getName());
										}
										boss.setLevel(num);
									}
									// 读取life
									{
										NodeList node = firstBossElement
												.getElementsByTagName("life");
										String str = node.item(0)
												.getChildNodes().item(0)
												.getNodeValue().trim();
										int num;
										try {
											num = Integer.parseInt(str);
										} catch (Exception e) {
											e.printStackTrace();
											throw new RuntimeException(
													"加载"
															+ file.getName()
															+ "时，specialNpc的life不是数字,name="
															+ boss.getName());
										}
										boss.setLifeTime(num);
									}
									// 读取appearTime
									{
										NodeList node = firstBossElement
												.getElementsByTagName("appearTime");
										String str = node.item(0)
												.getChildNodes().item(0)
												.getNodeValue().trim();
										String[] numStr = str.split(",");
										int num;
										for (int i = 0; i < numStr.length; i++) {
											if (numStr[i] == "") {
												continue;
											}
											try {
												num = Integer
														.parseInt(numStr[i]);
												boss.addAppearHour(num);
											} catch (Exception e) {
												e.printStackTrace();
												throw new RuntimeException(
														"加载"
																+ file
																		.getName()
																+ "时，specialNpc的appearTime不是数字,name="
																+ boss
																		.getName());
											}
										}
									}
									// 读取appearMap
									{
										NodeList node = firstBossElement
												.getElementsByTagName("appearMap");
										String str = node.item(0)
												.getChildNodes().item(0)
												.getNodeValue().trim();
										String[] numStr = str.split(",");
										int num;
										for (int i = 0; i < numStr.length; i++) {
											if (numStr[i] == "") {
												continue;
											}
											try {
												num = Integer
														.parseInt(numStr[i]);
												boss.addAppearMap(num);
											} catch (Exception e) {
												e.printStackTrace();
												throw new RuntimeException(
														"加载"
																+ file
																		.getName()
																+ "时，specialNpc的appearMap不是数字,name="
																+ boss
																		.getName());
											}
										}
									}

									// 读取minTeamNum
									{
										NodeList node = firstBossElement
												.getElementsByTagName("minTeamNum");
										String str = node.item(0)
												.getChildNodes().item(0)
												.getNodeValue().trim();
										int num;
										try {
											num = Integer.parseInt(str);
										} catch (Exception e) {
											e.printStackTrace();
											throw new RuntimeException(
													"加载"
															+ file.getName()
															+ "时，specialNpc的minTeamNum不是数字,name="
															+ boss.getName());
										}
										boss.setMinTeamNum(num);
									}

									// 读取type
									{
										NodeList node = firstBossElement
												.getElementsByTagName("type");
										String str = node.item(0)
												.getChildNodes().item(0)
												.getNodeValue().trim();
										boss.setBattleType(MmochatTaskType
												.valueOf(str));
									}

									// 读取battle
									NodeList finish_need_battle = firstBossElement
											.getElementsByTagName("battle");
									if (finish_need_battle.getLength() > 0) {

										Node finish_need_battleNode = finish_need_battle
												.item(0);
										if (finish_need_battleNode
												.getNodeType() == Node.ELEMENT_NODE) {
											try {
												Element finish_need_battleElement = (Element) finish_need_battleNode;
												MmochatNpcBattle npcBattle = MmochatMainService
														.createNpcBattleFromFile(finish_need_battleElement);
												boss.setBattle(npcBattle);
											} catch (Exception e) {
												e.printStackTrace();
												throw new RuntimeException(boss
														.getName()
														+ "配置出错!");
											}
										}

									}
								}
							}
						}
					}
				}
			} catch (SAXParseException err) {
				log.debug("** Parsing error" + ", line " + err.getLineNumber()
						+ ", uri " + err.getSystemId());
				log.debug(" " + err.getMessage());
				err.printStackTrace();
				throw new RuntimeException("MmochatNpcService初始化失败,请重启!");
			} catch (SAXException e) {
				Exception x = e.getException();
				((x == null) ? e : x).printStackTrace();
				throw new RuntimeException("MmochatNpcService初始化失败,请重启!");
			} catch (Throwable t) {
				t.printStackTrace();
				throw new RuntimeException("MmochatNpcService初始化失败,请重启!");
			}
		}
	}

	// class doTest implements Runnable {
	// int start, end;
	//
	// public doTest(int s, int e) {
	// this.start = s;
	// this.end = e;
	// }
	//
	// @Override
	// public void run() {
	// for (int i = 0; i < 200; i++) {
	// int s = start + i * 100;
	// int e = s + 100;
	// List<TestModel> testList = MmochatDao.test(s, e);
	// String info = "";
	// for (TestModel t : testList) {
	// int count = 0, count1 = 0;
	//
	// for (MmochatPackageGrid grid : t.getMyPackage().values()) {
	// if (grid != null) {
	// MmochatCommonObject obj = grid.getObject();
	// if (obj != null && obj.getPropType() != null
	// && obj.getPropType() == MmochatPropType.道尊令) {
	// count += obj.getOverlapNum();
	// } else if (obj != null && obj.getPropType() != null
	// && obj.getPropType() == MmochatPropType.天尊令) {
	// count1 += obj.getOverlapNum();
	// }
	// }
	// }
	// for (MmochatPackageGrid grid : t.getMyStorage().values()) {
	// if (grid != null) {
	// MmochatCommonObject obj = grid.getObject();
	// if (obj != null && obj.getPropType() != null
	// && obj.getPropType() == MmochatPropType.道尊令) {
	// count += obj.getOverlapNum();
	// } else if (obj != null && obj.getPropType() != null
	// && obj.getPropType() == MmochatPropType.天尊令) {
	// count1 += obj.getOverlapNum();
	// }
	// }
	// }
	//
	// if (count >= 20 || count1 >= 20) {
	// info += t.getRoleId() + "\t\t";
	// info += count + "个道，" + count1 + "个天\r\n";
	// }
	// }
	// if (info.length() > 0) {
	// MmochatUtil.writeToFile("objresult.txt", info);
	// }
	// synchronized (testLock) {
	// testCount += 100;
	// }
	// }
	// }
	//
	// }

	public static void dealOnlineRank(MmochatPlayer me) {
		// 物伤排行、法伤排行、防御排行、速度排行:Map<等级,Map<角色ID,角色信息>>
		int levelRank = me.getLevel() / 10 * 10;
		Map<Integer, MmochatRoleRankInfo> m = physicalRank.get(levelRank);
		if (m != null) {
			int myValue = me.getPhysicalAttack();
			MmochatRoleRankInfo info = m.get(me.getRoleId());
			if (info != null) {
				// 已经在排行中了，如果当前数值更大，则更新数值，否则不更新数值
				if (info.getValue() < myValue) {
					info.setValue(myValue);
				}
			} else {
				// 未在排行中。如果当前排行人数不到30人，则直接加入排行；否则找出最小的一个，对比后替换
				if (m.size() < 30) {
					MmochatRoleRankInfo myInfo = new MmochatRoleRankInfo();
					myInfo.setBmpId(me.getBmpId());
					myInfo.setRoleId(me.getRoleId());
					myInfo.setName(me.getName());
					myInfo.setValue(myValue);
					m.put(me.getRoleId(), myInfo);
				} else {
					Integer minValueRoleId = null;
					int curValue = Integer.MAX_VALUE;
					for (Entry<Integer, MmochatRoleRankInfo> entry : m
							.entrySet()) {
						MmochatRoleRankInfo hisInfo = entry.getValue();
						if (hisInfo.getValue() < curValue) {
							minValueRoleId = entry.getKey();
							curValue = hisInfo.getValue();
						}
					}
					if (minValueRoleId != null && curValue < myValue) {
						m.remove((int) minValueRoleId);
						MmochatRoleRankInfo myInfo = new MmochatRoleRankInfo();
						myInfo.setBmpId(me.getBmpId());
						myInfo.setRoleId(me.getRoleId());
						myInfo.setName(me.getName());
						myInfo.setValue(myValue);
						m.put(me.getRoleId(), myInfo);
					}
				}
			}
		}

		m = magicRank.get(levelRank);
		if (m != null) {
			int myValue = me.getSpritAttack();
			MmochatRoleRankInfo info = m.get(me.getRoleId());
			if (info != null) {
				// 已经在排行中了，如果当前数值更大，则更新数值，否则不更新数值
				if (info.getValue() < myValue) {
					info.setValue(myValue);
				}
			} else {
				// 未在排行中。如果当前排行人数不到30人，则直接加入排行；否则找出最小的一个，对比后替换
				if (m.size() < 30) {
					MmochatRoleRankInfo myInfo = new MmochatRoleRankInfo();
					myInfo.setBmpId(me.getBmpId());
					myInfo.setRoleId(me.getRoleId());
					myInfo.setName(me.getName());
					myInfo.setValue(myValue);
					m.put(me.getRoleId(), myInfo);
				} else {
					Integer minValueRoleId = null;
					int curValue = Integer.MAX_VALUE;
					for (Entry<Integer, MmochatRoleRankInfo> entry : m
							.entrySet()) {
						MmochatRoleRankInfo hisInfo = entry.getValue();
						if (hisInfo.getValue() < curValue) {
							minValueRoleId = entry.getKey();
							curValue = hisInfo.getValue();
						}
					}
					if (minValueRoleId != null && curValue < myValue) {
						m.remove((int) minValueRoleId);
						MmochatRoleRankInfo myInfo = new MmochatRoleRankInfo();
						myInfo.setBmpId(me.getBmpId());
						myInfo.setRoleId(me.getRoleId());
						myInfo.setName(me.getName());
						myInfo.setValue(myValue);
						m.put(me.getRoleId(), myInfo);
					}
				}
			}
		}

		m = speedRank.get(levelRank);
		if (m != null) {
			int myValue = me.getSpeed();
			MmochatRoleRankInfo info = m.get(me.getRoleId());
			if (info != null) {
				// 已经在排行中了，如果当前数值更大，则更新数值，否则不更新数值
				if (info.getValue() < myValue) {
					info.setValue(myValue);
				}
			} else {
				// 未在排行中。如果当前排行人数不到30人，则直接加入排行；否则找出最小的一个，对比后替换
				if (m.size() < 30) {
					MmochatRoleRankInfo myInfo = new MmochatRoleRankInfo();
					myInfo.setBmpId(me.getBmpId());
					myInfo.setRoleId(me.getRoleId());
					myInfo.setName(me.getName());
					myInfo.setValue(myValue);
					m.put(me.getRoleId(), myInfo);
				} else {
					Integer minValueRoleId = null;
					int curValue = Integer.MAX_VALUE;
					for (Entry<Integer, MmochatRoleRankInfo> entry : m
							.entrySet()) {
						MmochatRoleRankInfo hisInfo = entry.getValue();
						if (hisInfo.getValue() < curValue) {
							minValueRoleId = entry.getKey();
							curValue = hisInfo.getValue();
						}
					}
					if (minValueRoleId != null && curValue < myValue) {
						m.remove((int) minValueRoleId);
						MmochatRoleRankInfo myInfo = new MmochatRoleRankInfo();
						myInfo.setBmpId(me.getBmpId());
						myInfo.setRoleId(me.getRoleId());
						myInfo.setName(me.getName());
						myInfo.setValue(myValue);
						m.put(me.getRoleId(), myInfo);
					}
				}
			}
		}
	}

	public static void reloadEventLog() {
		try {
			long startTime1 = System.currentTimeMillis()
					- MmochatConstant.MS_PER_DAY * 90;
			List<MmochatEventLog> tmp = new ArrayList<MmochatEventLog>(
					MmochatDao.getAllEventLog(startTime1));
			Collections.sort(tmp);
			List<MmochatEventLog> bak = eventLogList;
			eventLogList = tmp;
			bak.clear();
			bak = null;
			tmp = null;
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	class loadEventLog implements Runnable {
		public void run() {
			// 加载所有活动日志,3个月内
			log.error("开始加载EventLog");
			long t1 = System.currentTimeMillis();
			long startTime1 = System.currentTimeMillis()
					- MmochatConstant.MS_PER_DAY * 90;
			eventLogList = new ArrayList<MmochatEventLog>(MmochatDao
					.getAllEventLog(startTime1));
			Collections.sort(eventLogList);
			log.error("load eventLog cost time:"
					+ (System.currentTimeMillis() - t1) + "ms");
		}
	}

	// 加载排行
	class loadRank implements Runnable {
		public void run() {
			try {
				log.error("开始加载排行");
				long t = System.currentTimeMillis();
				levelRank = MmochatDao.getTopLevelList();
				daoRank = MmochatDao.getTopDaoList();
				zhanJiRank = MmochatDao.getTopZhanjiList();
				moneyRank = MmochatDao.getTopSmallMoneyList();
				famousList.clear();
				if (levelRank != null) {
					for (MmochatRankPlayer me : levelRank) {
						famousList.put(me.getRoleId(), me.getRoleId());
						// 称号
						MmochatChenHao chenhao = new MmochatChenHao();
						chenhao.setType(MmochatChenHaoType.顶尖高手);
						chenhao.setExtraEffectInfo("荣登高手榜才能获得的称号!");
						chenhao.setLifeTime(MmochatConstant.MS_PER_DAY);
						MmochatChenHao.addAndUpdateChenHaoAndSaveSql(me
								.getRoleId(), chenhao);
					}
				}
				if (daoRank != null) {
					for (MmochatRankPlayer me : daoRank) {
						famousList.put(me.getRoleId(), me.getRoleId());
						// 称号
						MmochatChenHao chenhao = new MmochatChenHao();
						chenhao.setType(MmochatChenHaoType.道行高深);
						chenhao.setExtraEffectInfo("荣登道行总榜才能获得的称号!");
						chenhao.setLifeTime(MmochatConstant.MS_PER_DAY);
						MmochatChenHao.addAndUpdateChenHaoAndSaveSql(me
								.getRoleId(), chenhao);
					}
				}
				if (zhanJiRank != null) {
					for (MmochatRankPlayer me : zhanJiRank) {
						famousList.put(me.getRoleId(), me.getRoleId());
						// 称号
						MmochatChenHao chenhao = new MmochatChenHao();
						chenhao.setType(MmochatChenHaoType.战绩达人);
						chenhao.setExtraEffectInfo("荣登战绩榜才能获得的称号!");
						chenhao.setLifeTime(MmochatConstant.MS_PER_DAY);
						MmochatChenHao.addAndUpdateChenHaoAndSaveSql(me
								.getRoleId(), chenhao);
					}
				}
				if (moneyRank != null) {
					for (MmochatRankPlayer me : moneyRank) {
						famousList.put(me.getRoleId(), me.getRoleId());
						// 称号
						MmochatChenHao chenhao = new MmochatChenHao();
						chenhao.setType(MmochatChenHaoType.腰缠万贯);
						chenhao.setExtraEffectInfo("荣登财富榜才能获得的称号!");
						chenhao.setLifeTime(MmochatConstant.MS_PER_DAY);
						MmochatChenHao.addAndUpdateChenHaoAndSaveSql(me
								.getRoleId(), chenhao);
					}
				}

				daoRankOfLevel.clear();
				// 30、40、50、60、70、80、90、100、110、120
				for (int level = 30; level < 130; level += 10) {
					int minLevel = level;
					int maxLevel = level + 9;
					List<MmochatRankPlayer> tmpRank = MmochatDao
							.getTopDaoListByLevel(minLevel, maxLevel);
					daoRankOfLevel.put(level, tmpRank);
					if (tmpRank != null) {
						for (MmochatRankPlayer me : tmpRank) {
							famousList.put(me.getRoleId(), me.getRoleId());
						}
					}
				}
				log.error("load rank ok,cost time:"
						+ (System.currentTimeMillis() - t) + "ms");
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}

	// 定时检查临时NPC生命周期是否已过
	// 固定NPC身上的临时任务是否过期
	class checkBossLife implements Runnable {
		@Override
		public void run() {
			try {
				for (MmochatNpc npc : npcs.values()) {
					if (npc instanceof MmochatTempNpc) {
						MmochatTempNpc boss = (MmochatTempNpc) npc;
						if (boss.getState() == MmochatNpcState.战斗中
								&& System.currentTimeMillis()
										- boss.getCreateTime() < boss
										.getLifeTime()
										+ MmochatConstant.MS_PER_HOUR) {
							// 如果在战斗中，并且不超过生命时间+1小时，则不移除，等战斗结束时再移除
							continue;
						}
						if (boss.isTimeOut()) {
							boss.setState(MmochatNpcState.离开);
							npcs.remove(npc.getNpcId());
							MmochatMap curMap = MmochatMapService.maps.get(boss
									.getMapId());
							if (curMap != null) {
								// curMap.delNpc(boss.getLine(), npc);
								curMap.delNpc(npc);
							}
						}
					} else {
						// 固定NPC身上的临时任务是否过期
						for (MmochatTask task : npc.getTasks().values()) {
							if (task instanceof MmochatTempTask) {
								if (task.isInvalid()) {
									npc.getTasks().remove(task.getTaskId());
								}
							}
						}
					}
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}

	// 检查副本是否过期
	class checkFuBen implements Runnable {

		@Override
		public void run() {
			try {
				for (MmochatFuBen fuBen : fuBens.values()) {
					if (fuBen != null && fuBen.isTimeOut()) {
						// 副本过期
						fuBen.close();
						fuBens.remove(fuBen.getId());
					}
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
			try {
				for (MmochatGangFuBen fuBen : gangFuBens.values()) {
					if (fuBen != null && fuBen.isTimeOut()) {
						// 帮派副本过期
						fuBen.close();
						gangFuBens.remove(fuBen.getId());
					}
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
		}

	}

	class createMapBoss implements Runnable {
		@SuppressWarnings("deprecation")
		@Override
		public void run() {
			try {
				Date now = new Date();
				for (MmochatBossFactory bossFactory : activityBoss) {
					if (!bossFactory.getAppearHour().contains(now.getHours())) {
						continue;
					}
					for (int line = 0; line < MmochatConstant.maxMapLineNum; line++) {
						if (!MmochatUtil.isInPercent(15)) {
							continue;
						}
						int index = (int) (Math.random() * (bossFactory
								.getAppearMap().size()));
						int mapId = bossFactory.getAppearMap().get(index);

						MmochatPoint point = MmochatMapService
								.getRandReachablePoint(mapId);
						if (point != null) {
							MmochatTempNpc boss = new MmochatTempNpc(true);
							npcs.put(boss.getNpcId(), boss);
							boss.getFunctionItems().add(MmochatNpcItemType.击杀);
							boss.setLevel(bossFactory.getLevel());
							boss.setLifeTime(bossFactory.getLifeTime());
							boss.setLine(line);
							boss.setName(bossFactory.getName());
							boss.setBmpType(bossFactory.getBmpType());
							boss.setMapId(mapId);
							short x = (short) (point.getX() * 24 + Math
									.random() * 24);
							short y = (short) (point.getY() * 24 + Math
									.random() * 24);
							boss.setX(x);
							boss.setY(y);
							boss.setMinTeamNum(bossFactory.getMinTeamNum());

							MmochatMap theMap = MmochatMapService.maps
									.get(mapId);
							if (theMap == null) {
								continue;
							}
							theMap.addNpc(boss.getLine(), boss);

							MmochatTask newTask = new MmochatTask();
							newTask.setTaskId(0);
							boss.addTask(newTask);
							MmochatNpcBattle battle = bossFactory.getBattle();
							newTask.setFinish_need_battles(battle);
							newTask.setTaskType(bossFactory.getBattleType());

							// TODO:test
							log.debug("boss出现在" + theMap.getMapName()
									+ (line + 1) + "线(" + x + "," + y + ")");
						}

					}
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}

	// 获取NPC
	public static MmochatNpc getNpcById(int npcId) {
		MmochatNpc npc = npcs.get(npcId);
		if (npc != null) {
			return npc;
		} else {
			if (npcId != -1) {
				log.debug("没有找到npc,npcId=" + npcId);
			}
			return null;
		}
	}

	public static MmochatTask createYBTask(MmochatPlayer me,
			MmochatTaskType taskType, int curTaskTurn, int monsterNum,
			Integer nextAccept_taskId, int finish_npcId, String taskDetail,
			MmochatRoleBmpType bossBmp, String bossName, int antiGodSkill,
			int antiHumanSkill, int antiDevilSkill, int physicalDefendPercent) {
		// 创建新的任务
		MmochatTempTask newTask = new MmochatTempTask(true);
		newTask.setTaskType(taskType);
		newTask.setTaskTurn(curTaskTurn);
		newTask.setTaskName(newTask.getTaskType().toString());
		newTask.setTaskState(MmochatTaskStateType.已接);
		newTask.setFinish_npcId(finish_npcId);
		newTask.setTaskDetail(taskDetail);

		// finish_need_battles
		MmochatNpcBattle battle = new MmochatNpcBattle();
		newTask.setFinish_need_battles(battle);
		battle.setFinishTeamTask(true);
		MmochatMonsterFactory boss = new MmochatMonsterFactory();
		boss.setLevelType(MmochatBossLevelType.队伍最高等级);
		boss.setBmpType(bossBmp);
		boss.setName(bossName);
		boss.setLevel(me.getTrueLevel());
		boss.setEquipLevel(7);
		boss.setTeamNum(3);
		boss.setKillRound(2);
		boss.setPhysical(0.7);
		boss.setMagic(0.4);
		boss.setSuperPhysicalAttack(10);
		boss.setSuperSpritAttack(10);
		boss.setBossMaxSkillTargetNum(2);
		boss.setSpeedPointAddType(3);
		boss.setDao((int) (7 * MmochatBattleService.getStandardDao(me
				.getLevel(), me.getLife_turn())));
		boss.setAntiGodSkill(antiGodSkill);
		boss.setAntiHumanSkill(antiHumanSkill);
		boss.setAntiDevilSkill(antiDevilSkill);
		boss.setPhysicalDefendPercent(physicalDefendPercent);

		MmochatAttackModeOfNormal defaultAttackMode = new MmochatAttackModeOfNormal();
		defaultAttackMode.setPhysicalAttackOpportunity(70);
		defaultAttackMode.setMagicAttackOppotunity(30);
		defaultAttackMode.setLimitOppotunity(0);
		boss.setAttackMode_normal(defaultAttackMode);
		battle.setBoss(boss);

		monsterNum = monsterNum - 1;// 其中一个是主怪
		List<MmochatMonsterFactory> monsters = new ArrayList<MmochatMonsterFactory>();
		for (int i = 0; i < monsterNum; i++) {
			MmochatMonsterFactory monster = new MmochatMonsterFactory();
			monster.setLevelType(MmochatBossLevelType.队伍最高等级);
			monster.setBmpType(bossBmp);
			monster.setName(bossName);
			monster.setLevel(me.getTrueLevel());
			monster.setEquipLevel(7);
			monster.setTeamNum(3);
			monster.setKillRound(2);
			monster.setPhysical(0.7);
			monster.setMagic(0.4);
			monster.setSuperPhysicalAttack(10);
			monster.setSuperSpritAttack(10);
			monster.setBossMaxSkillTargetNum(2);
			monster.setSpeedPointAddType(3);
			monster.setDao((int) (7 * MmochatBattleService.getStandardDao(me
					.getLevel(), me.getLife_turn())));
			monster.setAntiGodSkill(antiGodSkill);
			monster.setAntiHumanSkill(antiHumanSkill);
			monster.setAntiDevilSkill(antiDevilSkill);
			monster.setPhysicalDefendPercent(physicalDefendPercent);

			MmochatAttackModeOfNormal monsterDefaultAttackMode = new MmochatAttackModeOfNormal();
			monsterDefaultAttackMode.setPhysicalAttackOpportunity(70);
			monsterDefaultAttackMode.setMagicAttackOppotunity(30);
			monsterDefaultAttackMode.setLimitOppotunity(0);
			monster.setAttackMode_normal(monsterDefaultAttackMode);

			monsters.add(monster);
		}
		battle.setSmallBoss(monsters);

		newTask.setNextAccept_taskId(nextAccept_taskId);
		newTask.setTaskLife(MmochatConstant.MS_PER_HOUR);

		return newTask;
	}

	// 9.1 NPC固定功能
	@SuppressWarnings( { "deprecation", "unchecked" })
	@SkymobiService
	public SkymobiProtocolMessage handleC_9_1(SkymobiHandler handler,
			Mmochat_9_1C req) {
		// TODO
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}

		synchronized (me) {
			MmochatNpcItemType type = MmochatNpcItemType.get(req
					.getFunctionValue());

			MmochatNpc npc = MmochatNpcService.npcs.get(req.getNpcId());
			if (npc == null) {
				return MmochatUtil.msgbox(req.getHallState(), "目标已经离开!");
			}
			if (npc.getMapId() != me.getMapId()
					|| Math.abs(me.getX() - npc.getX()) > 400
					|| Math.abs(me.getY() - npc.getY()) > 400) {
				// 与NPC不在同一地图或距离太远
				boolean canRomoteVisit = false;
				for (int romoteId : MmochatTaskService.romoteNpcIds) {
					if (romoteId == npc.getNpcId()) {
						// 允许远程访问
						canRomoteVisit = true;
						break;
					}
				}
				if (!canRomoteVisit) {
					return MmochatUtil.msgbox(req.getHallState(), "与目标距离太远!");
				}
			}
			SkymobiProtocolMessage subReq = dealHandleC_9_1_sub1(type, npc, req);
			if (subReq != null) {
				return subReq;
			}
			switch (type) {
			case 经验修炼: {
				long lastTimeCopy = 0;
				MmochatDailyActivity activity;

				synchronized (me) {
					activity = me.getDailyActivities().get(
							MmochatDailyActivityType.经验修炼);
					Date now = new Date();
					Date lastDate; // 上次参加活动日期
					if (activity == null) {
						lastDate = new Date();
					} else {
						lastDate = new Date(activity.getLastTime());
					}

					if (activity == null) {
						// 第一次参加此活动
						activity = new MmochatDailyActivity();
						activity.setType(MmochatDailyActivityType.经验修炼);
						me.addDailyActivity(activity);
					} else if (activity.isInActivity() == true) {
						// 已经在活动当中
						return MmochatUtil.msgbox(req.getHallState(), "您已经在"
								+ MmochatUtil.wrapColor(
										MmochatDailyActivityType.经验修炼
												.toString(), Color.yellow)
								+ "当中，请先领取"
								+ MmochatUtil.wrapColor(MmochatPropType.经验丹
										.toString(), Color.green)
								+ "或"
								+ MmochatUtil.wrapColor(MmochatPropType.经验果
										.toString(), Color.green)
								+ "，再进行下一次的"
								+ MmochatUtil.wrapColor(
										MmochatDailyActivityType.经验修炼
												.toString(), Color.yellow)
								+ "!");
					} else if (now.getDate() == lastDate.getDate()
							&& now.getMonth() == lastDate.getMonth()
							&& now.getYear() == lastDate.getYear()) {
						// 今天已经参加过此活动了
						return MmochatUtil.msgbox(req.getHallState(),
								"您今天已经进行过"
										+ MmochatUtil.wrapColor(
												MmochatDailyActivityType.经验修炼
														.toString(),
												Color.yellow) + "，请休息一下明天再来吧!");
					}

					if (me.getZhanji() < 100) {
						return MmochatUtil.msgbox(req.getHallState(),
								"您的战绩少于100点，无法进行"
										+ MmochatUtil.wrapColor(
												MmochatDailyActivityType.经验修炼
														.toString(),
												Color.yellow) + "!");
					}

					lastTimeCopy = activity.getLastTime(); // 保存原时间，以备恢复使用
					activity.setLastTime(now.getTime()); // 设置本次参加活动的时间
					activity.setInActivity(true);
				}

				me.addZhanji(-100);

				String info;
				info = "您消耗了100点战绩，开始进行"
						+ MmochatUtil.wrapColor(MmochatDailyActivityType.经验修炼
								.toString(), Color.yellow)
						+ "!6个小时后可来领取"
						+ MmochatUtil.wrapColor(MmochatPropType.经验丹.toString(),
								Color.green)
						+ "或"
						+ MmochatUtil.wrapColor(MmochatPropType.经验果.toString(),
								Color.green)
						+ "，每次只能选择一种领取，"
						+ MmochatUtil.wrapColor(MmochatPropType.经验丹.toString(),
								Color.green)
						+ "增加的经验是"
						+ MmochatUtil.wrapColor(MmochatPropType.经验果.toString(),
								Color.green)
						+ "的3倍，但需要消耗1个"
						+ MmochatUtil.wrapColor(MmochatPropType.超级炼丹剂
								.toString(), Color.green) + "!";

				try {
					MmochatDao.updateRoleDailyActivityAndZhanJi(me);
				} catch (Exception e) {
					e.printStackTrace();
					me.addZhanji(100);
					activity.setInActivity(false);
					activity.setLastTime(lastTimeCopy);
					return MmochatUtil
							.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
				}

				return MmochatUtil.msgbox(req.getHallState(), info);
			}
			case 领取经验果: {
				MmochatDailyActivity activity;

				synchronized (me) {
					activity = me.getDailyActivities().get(
							MmochatDailyActivityType.经验修炼);
					Date now = new Date(); // 目前时刻
					long duration; // 已修炼时间

					if (activity == null) {
						// 从未参加此活动
						return MmochatUtil.msgbox(req.getHallState(), "您还未进行"
								+ MmochatUtil.wrapColor(
										MmochatDailyActivityType.经验修炼
												.toString(), Color.yellow)
								+ "，请先进行"
								+ MmochatUtil.wrapColor(
										MmochatDailyActivityType.经验修炼
												.toString(), Color.yellow)
								+ "!");
					} else if (activity.isInActivity() == false) {
						// 未在活动当中
						return MmochatUtil.msgbox(req.getHallState(), "您还未进行"
								+ MmochatUtil.wrapColor(
										MmochatDailyActivityType.经验修炼
												.toString(), Color.yellow)
								+ "，请先进行"
								+ MmochatUtil.wrapColor(
										MmochatDailyActivityType.经验修炼
												.toString(), Color.yellow)
								+ "!");
					} else if ((duration = now.getTime()
							- activity.getLastTime()) < (MmochatConstant.MS_PER_HOUR * 6)) {
						// 修炼未满6小时
						long difference = MmochatConstant.MS_PER_HOUR * 6
								- duration;
						int hour = (int) difference
								/ (int) MmochatConstant.MS_PER_HOUR;
						int minute = (int) (difference - hour
								* MmochatConstant.MS_PER_HOUR)
								/ (int) MmochatConstant.MS_PER_MINUTE;
						return MmochatUtil.msgbox(req.getHallState(), "您的"
								+ MmochatUtil.wrapColor(
										MmochatDailyActivityType.经验修炼
												.toString(), Color.yellow)
								+ "还差" + hour + "小时" + minute
								+ "分钟才完成，请稍后再来领取!");
					}

					if (!me.hasEnoughPackageSpace(1)) {
						return MmochatUtil.msgbox(req.getHallState(),
								"请先将包裹清理出一个空位!");
					}

					activity.setInActivity(false);
				}

				// 设置经验果使用等级范围
				MmochatProp prop = new MmochatProp(MmochatPropType.经验果);
				int playerLevel = Math.max(me.getLevel(), 0);
				prop.setMinUseLevelOfProp(playerLevel);
				int updatePlayerLevel = Math.min(playerLevel + 10,
						MmochatConstant.maxLevel);
				prop.setMaxUseLevelOfProp(updatePlayerLevel);

				// 设置经验果增加经验值
				Map<MmochatRoleAttributeType, Double> attrMap = MmochatPetService.monsterBaseAttackData
						.get(playerLevel);
				int exp = 0;
				if (attrMap != null) {
					exp = (int) (attrMap.get(MmochatRoleAttributeType.杀死怪物经验) * 225);
				}
				prop.setExpAmountOfPropForPlayer(exp);

				me.addObjectToPackage(prop);

				String info;
				info = "您已领取一颗"
						+ MmochatUtil.wrapColor(MmochatPropType.经验果.toString(),
								Color.green) + "!";

				try {
					MmochatDao.updateRoleDailyActivityAndPackage(me);
				} catch (Exception e) {
					e.printStackTrace();
					me.delPackageObjById(prop.getId());
					activity.setInActivity(true);
					return MmochatUtil
							.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
				}

				return MmochatUtil.msgbox(req.getHallState(), info);
			}
			case 领取经验丹: {
				MmochatDailyActivity activity;
				MmochatPackageGrid grid;
				MmochatCommonObject objectCopy;

				synchronized (me) {
					activity = me.getDailyActivities().get(
							MmochatDailyActivityType.经验修炼);
					Date now = new Date(); // 目前时刻
					long duration; // 已修炼时间

					if (activity == null) {
						// 从未参加此活动
						return MmochatUtil.msgbox(req.getHallState(), "您还未进行"
								+ MmochatUtil.wrapColor(
										MmochatDailyActivityType.经验修炼
												.toString(), Color.yellow)
								+ "，请先进行"
								+ MmochatUtil.wrapColor(
										MmochatDailyActivityType.经验修炼
												.toString(), Color.yellow)
								+ "!");
					} else if (activity.isInActivity() == false) {
						// 未在活动当中
						return MmochatUtil.msgbox(req.getHallState(), "您还未进行"
								+ MmochatUtil.wrapColor(
										MmochatDailyActivityType.经验修炼
												.toString(), Color.yellow)
								+ "，请先进行"
								+ MmochatUtil.wrapColor(
										MmochatDailyActivityType.经验修炼
												.toString(), Color.yellow)
								+ "!");
					} else if ((duration = now.getTime()
							- activity.getLastTime()) < (MmochatConstant.MS_PER_HOUR * 6)) {
						// 修炼未满6小时
						long difference = MmochatConstant.MS_PER_HOUR * 6
								- duration;
						int hour = (int) difference
								/ (int) MmochatConstant.MS_PER_HOUR;
						int minute = (int) (difference - hour
								* MmochatConstant.MS_PER_HOUR)
								/ (int) MmochatConstant.MS_PER_MINUTE;
						return MmochatUtil.msgbox(req.getHallState(), "您的"
								+ MmochatUtil.wrapColor(
										MmochatDailyActivityType.经验修炼
												.toString(), Color.yellow)
								+ "还差" + hour + "小时" + minute
								+ "分钟才完成，请稍后再来领取!");
					}

					if (!me.hasEnoughPackageSpace(1)) {
						return MmochatUtil.msgbox(req.getHallState(),
								"请先将包裹清理出一个空位!");
					}

					// 扣除超级炼丹剂
					grid = me.getPackageGridOfObj(MmochatPropType.超级炼丹剂);
					if (grid == null || grid.getObject() == null
							|| grid.getObject().isUsedOut()) {
						return MmochatUtil.msgbox(req.getHallState(), "您的包裹中没有"
								+ MmochatUtil.wrapColor(MmochatPropType.超级炼丹剂
										.toString(), Color.green)
								+ "，不能领取"
								+ MmochatUtil.wrapColor(MmochatPropType.经验丹
										.toString(), Color.green)
								+ "!"
								+ MmochatUtil.wrapColor(MmochatPropType.超级炼丹剂
										.toString(), Color.green)
								+ "可按9键进入商城，在特色道具中购买!");
					}
					objectCopy = grid.getObject();
					objectCopy.delOverlapNum(1);
					if (objectCopy.isUsedOut()) {
						grid.setObject(null);
					}
					Mmochat_5_1S pack = new Mmochat_5_1S();
					pack.addGrid(grid);
					MmochatUtil.sendCommonPack(me, pack);

					activity.setInActivity(false);
				}

				// 设置经验丹使用等级范围
				MmochatProp prop = new MmochatProp(MmochatPropType.经验丹);
				int playerLevel = Math.max(me.getLevel(), 0);
				prop.setMinUseLevelOfProp(playerLevel);
				int updatePlayerLevel = Math.min(playerLevel + 10,
						MmochatConstant.maxLevel);
				prop.setMaxUseLevelOfProp(updatePlayerLevel);

				// 设置经验丹增加经验值
				Map<MmochatRoleAttributeType, Double> attrMap = MmochatPetService.monsterBaseAttackData
						.get(playerLevel);
				int exp = 0;
				if (attrMap != null) {
					exp = (int) (attrMap.get(MmochatRoleAttributeType.杀死怪物经验) * 675);
				}
				prop.setExpAmountOfPropForPlayer(exp);

				me.addObjectToPackage(prop);

				String info;
				info = "您消耗了一个超级炼丹剂，并已领取一颗"
						+ MmochatUtil.wrapColor(MmochatPropType.经验丹.toString(),
								Color.green) + "!";

				try {
					MmochatDao.updateRoleDailyActivityAndPackage(me);
				} catch (Exception e) {
					e.printStackTrace();
					me.delPackageObjById(prop.getId());
					activity.setInActivity(true);
					objectCopy.addOverlapNum(1);
					grid.setObject(objectCopy);
					return MmochatUtil
							.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
				}

				return MmochatUtil.msgbox(req.getHallState(), info);
			}
			case 道行修炼: {
				long lastTimeCopy = 0;
				MmochatDailyActivity activity;

				synchronized (me) {
					activity = me.getDailyActivities().get(
							MmochatDailyActivityType.道行修炼);
					Date now = new Date();
					Date lastDate; // 上次参加活动日期
					if (activity == null) {
						lastDate = new Date();
					} else {
						lastDate = new Date(activity.getLastTime());
					}

					if (activity == null) {
						// 第一次参加此活动
						activity = new MmochatDailyActivity();
						activity.setType(MmochatDailyActivityType.道行修炼);
						me.addDailyActivity(activity);
					} else if (activity.isInActivity() == true) {
						// 已经在活动当中
						return MmochatUtil.msgbox(req.getHallState(), "您已经在"
								+ MmochatUtil.wrapColor(
										MmochatDailyActivityType.道行修炼
												.toString(), Color.yellow)
								+ "当中，请先领取"
								+ MmochatUtil.wrapColor(MmochatPropType.道行丹
										.toString(), Color.green)
								+ "或"
								+ MmochatUtil.wrapColor(MmochatPropType.道行果
										.toString(), Color.green)
								+ "，再进行下一次的"
								+ MmochatUtil.wrapColor(
										MmochatDailyActivityType.道行修炼
												.toString(), Color.yellow)
								+ "!");
					} else if (now.getDate() == lastDate.getDate()
							&& now.getMonth() == lastDate.getMonth()
							&& now.getYear() == lastDate.getYear()) {
						// 今天已经参加过此活动了
						return MmochatUtil.msgbox(req.getHallState(),
								"您今天已经进行过"
										+ MmochatUtil.wrapColor(
												MmochatDailyActivityType.道行修炼
														.toString(),
												Color.yellow) + "，请休息一下明天再来吧!");
					}

					if (me.getZhanji() < 100) {
						return MmochatUtil.msgbox(req.getHallState(),
								"您的战绩少于100点，无法进行"
										+ MmochatUtil.wrapColor(
												MmochatDailyActivityType.道行修炼
														.toString(),
												Color.yellow) + "!");
					}

					lastTimeCopy = activity.getLastTime(); // 保存原时间，以备恢复使用
					activity.setLastTime(now.getTime()); // 设置本次参加活动的时间
					activity.setInActivity(true);
				}

				me.addZhanji(-100);

				String info;
				info = "您消耗了100点战绩，开始进行"
						+ MmochatUtil.wrapColor(MmochatDailyActivityType.道行修炼
								.toString(), Color.yellow)
						+ "!6个小时后可来领取"
						+ MmochatUtil.wrapColor(MmochatPropType.道行丹.toString(),
								Color.green)
						+ "或"
						+ MmochatUtil.wrapColor(MmochatPropType.道行果.toString(),
								Color.green)
						+ "，每次只能选择一种领取，"
						+ MmochatUtil.wrapColor(MmochatPropType.道行丹.toString(),
								Color.green)
						+ "增加的道行是"
						+ MmochatUtil.wrapColor(MmochatPropType.道行果.toString(),
								Color.green)
						+ "的3倍，但需要消耗1个"
						+ MmochatUtil.wrapColor(MmochatPropType.超级炼丹剂
								.toString(), Color.green) + "!";

				try {
					MmochatDao.updateRoleDailyActivityAndZhanJi(me);
				} catch (Exception e) {
					e.printStackTrace();
					me.addZhanji(100);
					activity.setInActivity(false);
					activity.setLastTime(lastTimeCopy);
					return MmochatUtil
							.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
				}

				return MmochatUtil.msgbox(req.getHallState(), info);
			}
			case 领取道行果: {
				MmochatDailyActivity activity;

				synchronized (me) {
					activity = me.getDailyActivities().get(
							MmochatDailyActivityType.道行修炼);
					Date now = new Date(); // 目前时刻
					long duration; // 已修炼时间

					if (activity == null) {
						// 从未参加此活动
						return MmochatUtil.msgbox(req.getHallState(), "您还未进行"
								+ MmochatUtil.wrapColor(
										MmochatDailyActivityType.道行修炼
												.toString(), Color.yellow)
								+ "，请先进行"
								+ MmochatUtil.wrapColor(
										MmochatDailyActivityType.道行修炼
												.toString(), Color.yellow)
								+ "!");
					} else if (activity.isInActivity() == false) {
						// 未在活动当中
						return MmochatUtil.msgbox(req.getHallState(), "您还未进行"
								+ MmochatUtil.wrapColor(
										MmochatDailyActivityType.道行修炼
												.toString(), Color.yellow)
								+ "，请先进行"
								+ MmochatUtil.wrapColor(
										MmochatDailyActivityType.道行修炼
												.toString(), Color.yellow)
								+ "!");
					} else if ((duration = now.getTime()
							- activity.getLastTime()) < (MmochatConstant.MS_PER_HOUR * 6)) {
						// 修炼未满6小时
						long difference = MmochatConstant.MS_PER_HOUR * 6
								- duration;
						int hour = (int) difference
								/ (int) MmochatConstant.MS_PER_HOUR;
						int minute = (int) (difference - hour
								* MmochatConstant.MS_PER_HOUR)
								/ (int) MmochatConstant.MS_PER_MINUTE;
						return MmochatUtil.msgbox(req.getHallState(), "您的"
								+ MmochatUtil.wrapColor(
										MmochatDailyActivityType.道行修炼
												.toString(), Color.yellow)
								+ "还差" + hour + "小时" + minute
								+ "分钟才完成，请稍后再来领取!");
					}

					if (!me.hasEnoughPackageSpace(1)) {
						return MmochatUtil.msgbox(req.getHallState(),
								"请先将包裹清理出一个空位!");
					}

					activity.setInActivity(false);
				}

				// 设置道行果增加道行值
				MmochatProp prop = new MmochatProp(MmochatPropType.道行果);
				int dao = 548;
				prop.setDaoAmountOfPropForPlayer(dao);

				me.addObjectToPackage(prop);

				String info;
				info = "您已领取一颗"
						+ MmochatUtil.wrapColor(MmochatPropType.道行果.toString(),
								Color.green) + "!";

				try {
					MmochatDao.updateRoleDailyActivityAndPackage(me);
				} catch (Exception e) {
					e.printStackTrace();
					me.delPackageObjById(prop.getId());
					activity.setInActivity(true);
					return MmochatUtil
							.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
				}

				return MmochatUtil.msgbox(req.getHallState(), info);
			}
			case 领取道行丹: {
				MmochatDailyActivity activity;
				MmochatPackageGrid grid;
				MmochatCommonObject objectCopy;

				synchronized (me) {
					activity = me.getDailyActivities().get(
							MmochatDailyActivityType.道行修炼);
					Date now = new Date(); // 目前时刻
					long duration; // 已修炼时间

					if (activity == null) {
						// 从未参加此活动
						return MmochatUtil.msgbox(req.getHallState(), "您还未进行"
								+ MmochatUtil.wrapColor(
										MmochatDailyActivityType.道行修炼
												.toString(), Color.yellow)
								+ "，请先进行"
								+ MmochatUtil.wrapColor(
										MmochatDailyActivityType.道行修炼
												.toString(), Color.yellow)
								+ "!");
					} else if (activity.isInActivity() == false) {
						// 未在活动当中
						return MmochatUtil.msgbox(req.getHallState(), "您还未进行"
								+ MmochatUtil.wrapColor(
										MmochatDailyActivityType.道行修炼
												.toString(), Color.yellow)
								+ "，请先进行"
								+ MmochatUtil.wrapColor(
										MmochatDailyActivityType.道行修炼
												.toString(), Color.yellow)
								+ "!");
					} else if ((duration = now.getTime()
							- activity.getLastTime()) < (MmochatConstant.MS_PER_HOUR * 6)) {
						// 修炼未满6小时
						long difference = MmochatConstant.MS_PER_HOUR * 6
								- duration;
						int hour = (int) difference
								/ (int) MmochatConstant.MS_PER_HOUR;
						int minute = (int) (difference - hour
								* MmochatConstant.MS_PER_HOUR)
								/ (int) MmochatConstant.MS_PER_MINUTE;
						return MmochatUtil.msgbox(req.getHallState(), "您的"
								+ MmochatUtil.wrapColor(
										MmochatDailyActivityType.道行修炼
												.toString(), Color.yellow)
								+ "还差" + hour + "小时" + minute
								+ "分钟才完成，请稍后再来领取!");
					}

					if (!me.hasEnoughPackageSpace(1)) {
						return MmochatUtil.msgbox(req.getHallState(),
								"请先将包裹清理出一个空位!");
					}

					// 扣除超级炼丹剂
					grid = me.getPackageGridOfObj(MmochatPropType.超级炼丹剂);
					if (grid == null || grid.getObject() == null
							|| grid.getObject().isUsedOut()) {
						return MmochatUtil.msgbox(req.getHallState(), "您的包裹中没有"
								+ MmochatUtil.wrapColor(MmochatPropType.超级炼丹剂
										.toString(), Color.green)
								+ "，不能领取"
								+ MmochatUtil.wrapColor(MmochatPropType.道行丹
										.toString(), Color.green)
								+ "!"
								+ MmochatUtil.wrapColor(MmochatPropType.超级炼丹剂
										.toString(), Color.green)
								+ "可按9键进入商城，在特色道具中购买!");
					}
					objectCopy = grid.getObject();
					objectCopy.delOverlapNum(1);
					if (objectCopy.isUsedOut()) {
						grid.setObject(null);
					}
					Mmochat_5_1S pack = new Mmochat_5_1S();
					pack.addGrid(grid);
					MmochatUtil.sendCommonPack(me, pack);

					activity.setInActivity(false);
				}

				// 设置道行丹增加道行值
				MmochatProp prop = new MmochatProp(MmochatPropType.道行丹);
				int dao = 1643;
				prop.setDaoAmountOfPropForPlayer(dao);

				me.addObjectToPackage(prop);

				String info;
				info = "您消耗了一个超级炼丹剂，并已领取一颗"
						+ MmochatUtil.wrapColor(MmochatPropType.道行丹.toString(),
								Color.green) + "!";

				try {
					MmochatDao.updateRoleDailyActivityAndPackage(me);
				} catch (Exception e) {
					e.printStackTrace();
					me.delPackageObjById(prop.getId());
					activity.setInActivity(true);
					objectCopy.addOverlapNum(1);
					grid.setObject(objectCopy);
					return MmochatUtil
							.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
				}

				return MmochatUtil.msgbox(req.getHallState(), info);
			}
			case 宠物经验修炼: {
				long lastTimeCopy = 0;
				MmochatDailyActivity activity;

				synchronized (me) {
					activity = me.getDailyActivities().get(
							MmochatDailyActivityType.宠物经验修炼);
					Date now = new Date();
					Date lastDate; // 上次参加活动日期
					if (activity == null) {
						lastDate = new Date();
					} else {
						lastDate = new Date(activity.getLastTime());
					}

					if (activity == null) {
						// 第一次参加此活动
						activity = new MmochatDailyActivity();
						activity.setType(MmochatDailyActivityType.宠物经验修炼);
						me.addDailyActivity(activity);
					} else if (activity.isInActivity() == true) {
						// 已经在活动当中
						return MmochatUtil.msgbox(req.getHallState(), "您已经在"
								+ MmochatUtil.wrapColor(
										MmochatDailyActivityType.宠物经验修炼
												.toString(), Color.yellow)
								+ "当中，请先领取"
								+ MmochatUtil.wrapColor(MmochatPropType.宠物经验丹
										.toString(), Color.green)
								+ "或"
								+ MmochatUtil.wrapColor(MmochatPropType.宠物经验果
										.toString(), Color.green)
								+ "，再进行下一次的"
								+ MmochatUtil.wrapColor(
										MmochatDailyActivityType.宠物经验修炼
												.toString(), Color.yellow)
								+ "!");
					} else if (now.getDate() == lastDate.getDate()
							&& now.getMonth() == lastDate.getMonth()
							&& now.getYear() == lastDate.getYear()) {
						// 今天已经参加过此活动了
						return MmochatUtil.msgbox(req.getHallState(),
								"您今天已经进行过"
										+ MmochatUtil.wrapColor(
												MmochatDailyActivityType.宠物经验修炼
														.toString(),
												Color.yellow) + "，请休息一下明天再来吧!");
					}

					if (me.getZhanji() < 100) {
						return MmochatUtil.msgbox(req.getHallState(),
								"您的战绩少于100点，无法进行"
										+ MmochatUtil.wrapColor(
												MmochatDailyActivityType.宠物经验修炼
														.toString(),
												Color.yellow) + "!");
					}

					lastTimeCopy = activity.getLastTime(); // 保存原时间，以备恢复使用
					activity.setLastTime(now.getTime()); // 设置本次参加活动的时间
					activity.setInActivity(true);
				}

				me.addZhanji(-100);

				String info;
				info = "您消耗了100点战绩，开始进行"
						+ MmochatUtil.wrapColor(MmochatDailyActivityType.宠物经验修炼
								.toString(), Color.yellow)
						+ "!6个小时后可来领取"
						+ MmochatUtil.wrapColor(MmochatPropType.宠物经验丹
								.toString(), Color.green)
						+ "或"
						+ MmochatUtil.wrapColor(MmochatPropType.宠物经验果
								.toString(), Color.green)
						+ "，每次只能选择一种领取，"
						+ MmochatUtil.wrapColor(MmochatPropType.宠物经验丹
								.toString(), Color.green)
						+ "增加的经验是"
						+ MmochatUtil.wrapColor(MmochatPropType.宠物经验果
								.toString(), Color.green)
						+ "的3倍，但需要消耗1个"
						+ MmochatUtil.wrapColor(MmochatPropType.超级炼丹剂
								.toString(), Color.green) + "!";

				try {
					MmochatDao.updateRoleDailyActivityAndZhanJi(me);
				} catch (Exception e) {
					e.printStackTrace();
					me.addZhanji(100);
					activity.setInActivity(false);
					activity.setLastTime(lastTimeCopy);
					return MmochatUtil
							.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
				}

				return MmochatUtil.msgbox(req.getHallState(), info);
			}
			case 领取宠物经验果: {
				MmochatDailyActivity activity;

				synchronized (me) {
					activity = me.getDailyActivities().get(
							MmochatDailyActivityType.宠物经验修炼);
					Date now = new Date(); // 目前时刻
					long duration; // 已修炼时间

					if (activity == null) {
						// 从未参加此活动
						return MmochatUtil.msgbox(req.getHallState(), "您还未进行"
								+ MmochatUtil.wrapColor(
										MmochatDailyActivityType.宠物经验修炼
												.toString(), Color.yellow)
								+ "，请先进行"
								+ MmochatUtil.wrapColor(
										MmochatDailyActivityType.宠物经验修炼
												.toString(), Color.yellow)
								+ "!");
					} else if (activity.isInActivity() == false) {
						// 未在活动当中
						return MmochatUtil.msgbox(req.getHallState(), "您还未进行"
								+ MmochatUtil.wrapColor(
										MmochatDailyActivityType.宠物经验修炼
												.toString(), Color.yellow)
								+ "，请先进行"
								+ MmochatUtil.wrapColor(
										MmochatDailyActivityType.宠物经验修炼
												.toString(), Color.yellow)
								+ "!");
					} else if ((duration = now.getTime()
							- activity.getLastTime()) < (MmochatConstant.MS_PER_HOUR * 6)) {
						// 修炼未满6小时
						long difference = MmochatConstant.MS_PER_HOUR * 6
								- duration;
						int hour = (int) difference
								/ (int) MmochatConstant.MS_PER_HOUR;
						int minute = (int) (difference - hour
								* MmochatConstant.MS_PER_HOUR)
								/ (int) MmochatConstant.MS_PER_MINUTE;
						return MmochatUtil.msgbox(req.getHallState(), "您的"
								+ MmochatUtil.wrapColor(
										MmochatDailyActivityType.宠物经验修炼
												.toString(), Color.yellow)
								+ "还差" + hour + "小时" + minute
								+ "分钟才完成，请稍后再来领取!");
					}

					if (!me.hasEnoughPackageSpace(1)) {
						return MmochatUtil.msgbox(req.getHallState(),
								"请先将包裹清理出一个空位!");
					}

					activity.setInActivity(false);
				}

				// 设置宠物经验果使用等级范围
				MmochatProp prop = new MmochatProp(MmochatPropType.宠物经验果);
				int playerLevel = Math.max(me.getLevel(), 0);
				prop.setMinUseLevelOfProp(playerLevel);
				int updatePlayerLevel = Math.min(playerLevel + 10,
						MmochatConstant.maxLevel);
				prop.setMaxUseLevelOfProp(updatePlayerLevel);

				// 设置宠物经验果增加经验值
				Map<MmochatRoleAttributeType, Double> attrMap = MmochatPetService.monsterBaseAttackData
						.get(playerLevel);
				int exp = 0;
				if (attrMap != null) {
					exp = (int) (attrMap.get(MmochatRoleAttributeType.杀死怪物经验) * 225);
				}
				prop.setExpAmountOfPropForPet(exp);

				me.addObjectToPackage(prop);

				String info;
				info = "您已领取一颗"
						+ MmochatUtil.wrapColor(MmochatPropType.宠物经验果
								.toString(), Color.green) + "!";

				try {
					MmochatDao.updateRoleDailyActivityAndPackage(me);
				} catch (Exception e) {
					e.printStackTrace();
					me.delPackageObjById(prop.getId());
					activity.setInActivity(true);
					return MmochatUtil
							.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
				}

				return MmochatUtil.msgbox(req.getHallState(), info);
			}
			case 领取宠物经验丹: {
				MmochatDailyActivity activity;
				MmochatPackageGrid grid;
				MmochatCommonObject objectCopy;

				synchronized (me) {
					activity = me.getDailyActivities().get(
							MmochatDailyActivityType.宠物经验修炼);
					Date now = new Date(); // 目前时刻
					long duration; // 已修炼时间

					if (activity == null) {
						// 从未参加此活动
						return MmochatUtil.msgbox(req.getHallState(), "您还未进行"
								+ MmochatUtil.wrapColor(
										MmochatDailyActivityType.宠物经验修炼
												.toString(), Color.yellow)
								+ "，请先进行"
								+ MmochatUtil.wrapColor(
										MmochatDailyActivityType.宠物经验修炼
												.toString(), Color.yellow)
								+ "!");
					} else if (activity.isInActivity() == false) {
						// 未在活动当中
						return MmochatUtil.msgbox(req.getHallState(), "您还未进行"
								+ MmochatUtil.wrapColor(
										MmochatDailyActivityType.宠物经验修炼
												.toString(), Color.yellow)
								+ "，请先进行"
								+ MmochatUtil.wrapColor(
										MmochatDailyActivityType.宠物经验修炼
												.toString(), Color.yellow)
								+ "!");
					} else if ((duration = now.getTime()
							- activity.getLastTime()) < (MmochatConstant.MS_PER_HOUR * 6)) {
						// 修炼未满6小时
						long difference = MmochatConstant.MS_PER_HOUR * 6
								- duration;
						int hour = (int) difference
								/ (int) MmochatConstant.MS_PER_HOUR;
						int minute = (int) (difference - hour
								* MmochatConstant.MS_PER_HOUR)
								/ (int) MmochatConstant.MS_PER_MINUTE;
						return MmochatUtil.msgbox(req.getHallState(), "您的"
								+ MmochatUtil.wrapColor(
										MmochatDailyActivityType.宠物经验修炼
												.toString(), Color.yellow)
								+ "还差" + hour + "小时" + minute
								+ "分钟才完成，请稍后再来领取!");
					}

					if (!me.hasEnoughPackageSpace(1)) {
						return MmochatUtil.msgbox(req.getHallState(),
								"请先将包裹清理出一个空位!");
					}

					// 扣除超级炼丹剂
					grid = me.getPackageGridOfObj(MmochatPropType.超级炼丹剂);
					if (grid == null || grid.getObject() == null
							|| grid.getObject().isUsedOut()) {
						return MmochatUtil.msgbox(req.getHallState(), "您的包裹中没有"
								+ MmochatUtil.wrapColor(MmochatPropType.超级炼丹剂
										.toString(), Color.green)
								+ "，不能领取"
								+ MmochatUtil.wrapColor(MmochatPropType.宠物经验丹
										.toString(), Color.green)
								+ "!"
								+ MmochatUtil.wrapColor(MmochatPropType.超级炼丹剂
										.toString(), Color.green)
								+ "可按9键进入商城，在特色道具中购买!");
					}
					objectCopy = grid.getObject();
					objectCopy.delOverlapNum(1);
					if (objectCopy.isUsedOut()) {
						grid.setObject(null);
					}
					Mmochat_5_1S pack = new Mmochat_5_1S();
					pack.addGrid(grid);
					MmochatUtil.sendCommonPack(me, pack);

					activity.setInActivity(false);
				}

				// 设置宠物经验丹使用等级范围
				MmochatProp prop = new MmochatProp(MmochatPropType.宠物经验丹);
				int playerLevel = Math.max(me.getLevel(), 0);
				prop.setMinUseLevelOfProp(playerLevel);
				int updatePlayerLevel = Math.min(playerLevel + 10,
						MmochatConstant.maxLevel);
				prop.setMaxUseLevelOfProp(updatePlayerLevel);

				// 设置宠物经验丹增加经验值
				Map<MmochatRoleAttributeType, Double> attrMap = MmochatPetService.monsterBaseAttackData
						.get(playerLevel);
				int exp = 0;
				if (attrMap != null) {
					exp = (int) (attrMap.get(MmochatRoleAttributeType.杀死怪物经验) * 675);
				}
				prop.setExpAmountOfPropForPet(exp);

				me.addObjectToPackage(prop);

				String info;
				info = "您消耗了一个超级炼丹剂，并已领取一颗"
						+ MmochatUtil.wrapColor(MmochatPropType.宠物经验丹
								.toString(), Color.green) + "!";

				try {
					MmochatDao.updateRoleDailyActivityAndPackage(me);
				} catch (Exception e) {
					e.printStackTrace();
					me.delPackageObjById(prop.getId());
					activity.setInActivity(true);
					objectCopy.addOverlapNum(1);
					grid.setObject(objectCopy);
					return MmochatUtil
							.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
				}

				return MmochatUtil.msgbox(req.getHallState(), info);
			}
			case 宠物武学修炼: {
				long lastTimeCopy = 0;
				MmochatDailyActivity activity;

				synchronized (me) {
					activity = me.getDailyActivities().get(
							MmochatDailyActivityType.宠物武学修炼);
					Date now = new Date();
					Date lastDate; // 上次参加活动日期
					if (activity == null) {
						lastDate = new Date();
					} else {
						lastDate = new Date(activity.getLastTime());
					}

					if (activity == null) {
						// 第一次参加此活动
						activity = new MmochatDailyActivity();
						activity.setType(MmochatDailyActivityType.宠物武学修炼);
						me.addDailyActivity(activity);
					} else if (activity.isInActivity() == true) {
						// 已经在活动当中
						return MmochatUtil.msgbox(req.getHallState(), "您已经在"
								+ MmochatUtil.wrapColor(
										MmochatDailyActivityType.宠物武学修炼
												.toString(), Color.yellow)
								+ "当中，请先领取"
								+ MmochatUtil.wrapColor(MmochatPropType.宠物武学丹
										.toString(), Color.green)
								+ "或"
								+ MmochatUtil.wrapColor(MmochatPropType.宠物武学果
										.toString(), Color.green)
								+ "，再进行下一次的"
								+ MmochatUtil.wrapColor(
										MmochatDailyActivityType.宠物武学修炼
												.toString(), Color.yellow)
								+ "!");
					} else if (now.getDate() == lastDate.getDate()
							&& now.getMonth() == lastDate.getMonth()
							&& now.getYear() == lastDate.getYear()) {
						// 今天已经参加过此活动了
						return MmochatUtil.msgbox(req.getHallState(),
								"您今天已经进行过"
										+ MmochatUtil.wrapColor(
												MmochatDailyActivityType.宠物武学修炼
														.toString(),
												Color.yellow) + "，请休息一下明天再来吧!");
					}

					if (me.getZhanji() < 100) {
						return MmochatUtil.msgbox(req.getHallState(),
								"您的战绩少于100点，无法进行"
										+ MmochatUtil.wrapColor(
												MmochatDailyActivityType.宠物武学修炼
														.toString(),
												Color.yellow) + "!");
					}

					lastTimeCopy = activity.getLastTime(); // 保存原时间，以备恢复使用
					activity.setLastTime(now.getTime()); // 设置本次参加活动的时间
					activity.setInActivity(true);
				}

				me.addZhanji(-100);

				String info;
				info = "您消耗了100点战绩，开始进行"
						+ MmochatUtil.wrapColor(MmochatDailyActivityType.宠物武学修炼
								.toString(), Color.yellow)
						+ "!6个小时后可来领取"
						+ MmochatUtil.wrapColor(MmochatPropType.宠物武学丹
								.toString(), Color.green)
						+ "或"
						+ MmochatUtil.wrapColor(MmochatPropType.宠物武学果
								.toString(), Color.green)
						+ "，每次只能选择一种领取，"
						+ MmochatUtil.wrapColor(MmochatPropType.宠物武学丹
								.toString(), Color.green)
						+ "增加的武学是"
						+ MmochatUtil.wrapColor(MmochatPropType.宠物武学果
								.toString(), Color.green)
						+ "的3倍，但需要消耗1个"
						+ MmochatUtil.wrapColor(MmochatPropType.超级炼丹剂
								.toString(), Color.green) + "!";

				try {
					MmochatDao.updateRoleDailyActivityAndZhanJi(me);
				} catch (Exception e) {
					e.printStackTrace();
					me.addZhanji(100);
					activity.setInActivity(false);
					activity.setLastTime(lastTimeCopy);
					return MmochatUtil
							.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
				}

				return MmochatUtil.msgbox(req.getHallState(), info);
			}
			case 领取宠物武学果: {
				MmochatDailyActivity activity;

				synchronized (me) {
					activity = me.getDailyActivities().get(
							MmochatDailyActivityType.宠物武学修炼);
					Date now = new Date(); // 目前时刻
					long duration; // 已修炼时间

					if (activity == null) {
						// 从未参加此活动
						return MmochatUtil.msgbox(req.getHallState(), "您还未进行"
								+ MmochatUtil.wrapColor(
										MmochatDailyActivityType.宠物武学修炼
												.toString(), Color.yellow)
								+ "，请先进行"
								+ MmochatUtil.wrapColor(
										MmochatDailyActivityType.宠物武学修炼
												.toString(), Color.yellow)
								+ "!");
					} else if (activity.isInActivity() == false) {
						// 未在活动当中
						return MmochatUtil.msgbox(req.getHallState(), "您还未进行"
								+ MmochatUtil.wrapColor(
										MmochatDailyActivityType.宠物武学修炼
												.toString(), Color.yellow)
								+ "，请先进行"
								+ MmochatUtil.wrapColor(
										MmochatDailyActivityType.宠物武学修炼
												.toString(), Color.yellow)
								+ "!");
					} else if ((duration = now.getTime()
							- activity.getLastTime()) < (MmochatConstant.MS_PER_HOUR * 6)) {
						// 修炼未满6小时
						long difference = MmochatConstant.MS_PER_HOUR * 6
								- duration;
						int hour = (int) difference
								/ (int) MmochatConstant.MS_PER_HOUR;
						int minute = (int) (difference - hour
								* MmochatConstant.MS_PER_HOUR)
								/ (int) MmochatConstant.MS_PER_MINUTE;
						return MmochatUtil.msgbox(req.getHallState(), "您的"
								+ MmochatUtil.wrapColor(
										MmochatDailyActivityType.宠物武学修炼
												.toString(), Color.yellow)
								+ "还差" + hour + "小时" + minute
								+ "分钟才完成，请稍后再来领取!");
					}

					if (!me.hasEnoughPackageSpace(1)) {
						return MmochatUtil.msgbox(req.getHallState(),
								"请先将包裹清理出一个空位!");
					}

					activity.setInActivity(false);
				}

				// 设置宠物武学果增加武学值
				MmochatProp prop = new MmochatProp(MmochatPropType.宠物武学果);
				int dao = 548;
				prop.setDaoAmountOfPropForPet(dao);

				me.addObjectToPackage(prop);

				String info;
				info = "您已领取一颗"
						+ MmochatUtil.wrapColor(MmochatPropType.宠物武学果
								.toString(), Color.green) + "!";

				try {
					MmochatDao.updateRoleDailyActivityAndPackage(me);
				} catch (Exception e) {
					e.printStackTrace();
					me.delPackageObjById(prop.getId());
					activity.setInActivity(true);
					return MmochatUtil
							.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
				}

				return MmochatUtil.msgbox(req.getHallState(), info);
			}
			case 领取宠物武学丹: {
				MmochatDailyActivity activity;
				MmochatPackageGrid grid;
				MmochatCommonObject objectCopy;

				synchronized (me) {
					activity = me.getDailyActivities().get(
							MmochatDailyActivityType.宠物武学修炼);
					Date now = new Date(); // 目前时刻
					long duration; // 已修炼时间

					if (activity == null) {
						// 从未参加此活动
						return MmochatUtil.msgbox(req.getHallState(), "您还未进行"
								+ MmochatUtil.wrapColor(
										MmochatDailyActivityType.宠物武学修炼
												.toString(), Color.yellow)
								+ "，请先进行"
								+ MmochatUtil.wrapColor(
										MmochatDailyActivityType.宠物武学修炼
												.toString(), Color.yellow)
								+ "!");
					} else if (activity.isInActivity() == false) {
						// 未在活动当中
						return MmochatUtil.msgbox(req.getHallState(), "您还未进行"
								+ MmochatUtil.wrapColor(
										MmochatDailyActivityType.宠物武学修炼
												.toString(), Color.yellow)
								+ "，请先进行"
								+ MmochatUtil.wrapColor(
										MmochatDailyActivityType.宠物武学修炼
												.toString(), Color.yellow)
								+ "!");
					} else if ((duration = now.getTime()
							- activity.getLastTime()) < (MmochatConstant.MS_PER_HOUR * 6)) {
						// 修炼未满6小时
						long difference = MmochatConstant.MS_PER_HOUR * 6
								- duration;
						int hour = (int) difference
								/ (int) MmochatConstant.MS_PER_HOUR;
						int minute = (int) (difference - hour
								* MmochatConstant.MS_PER_HOUR)
								/ (int) MmochatConstant.MS_PER_MINUTE;
						return MmochatUtil.msgbox(req.getHallState(), "您的"
								+ MmochatUtil.wrapColor(
										MmochatDailyActivityType.宠物武学修炼
												.toString(), Color.yellow)
								+ "还差" + hour + "小时" + minute
								+ "分钟才完成，请稍后再来领取!");
					}

					if (!me.hasEnoughPackageSpace(1)) {
						return MmochatUtil.msgbox(req.getHallState(),
								"请先将包裹清理出一个空位!");
					}

					// 扣除超级炼丹剂
					grid = me.getPackageGridOfObj(MmochatPropType.超级炼丹剂);
					if (grid == null || grid.getObject() == null
							|| grid.getObject().isUsedOut()) {
						return MmochatUtil.msgbox(req.getHallState(), "您的包裹中没有"
								+ MmochatUtil.wrapColor(MmochatPropType.超级炼丹剂
										.toString(), Color.green)
								+ "，不能领取"
								+ MmochatUtil.wrapColor(MmochatPropType.宠物武学丹
										.toString(), Color.green)
								+ "!"
								+ MmochatUtil.wrapColor(MmochatPropType.超级炼丹剂
										.toString(), Color.green)
								+ "可按9键进入商城，在特色道具中购买!");
					}
					objectCopy = grid.getObject();
					objectCopy.delOverlapNum(1);
					if (objectCopy.isUsedOut()) {
						grid.setObject(null);
					}
					Mmochat_5_1S pack = new Mmochat_5_1S();
					pack.addGrid(grid);
					MmochatUtil.sendCommonPack(me, pack);

					activity.setInActivity(false);
				}

				// 设置宠物武学丹增加武学值
				MmochatProp prop = new MmochatProp(MmochatPropType.宠物武学丹);
				int dao = 1643;
				prop.setDaoAmountOfPropForPet(dao);

				me.addObjectToPackage(prop);

				String info;
				info = "您消耗了一个超级炼丹剂，并已领取一颗"
						+ MmochatUtil.wrapColor(MmochatPropType.宠物武学丹
								.toString(), Color.green) + "!";

				try {
					MmochatDao.updateRoleDailyActivityAndPackage(me);
				} catch (Exception e) {
					e.printStackTrace();
					me.delPackageObjById(prop.getId());
					activity.setInActivity(true);
					objectCopy.addOverlapNum(1);
					grid.setObject(objectCopy);
					return MmochatUtil
							.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
				}

				return MmochatUtil.msgbox(req.getHallState(), info);
			}
			case 领取神行法宝: {
				CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
				String msg = "领取神行法宝需要扣除"
						+ MmochatUtil.wrapColor("5个神行法宝残片", Color.yellow)
						+ "(商城有售),你已经准备好残片了么?";
				msgbox.setContent(new Text(msg));
				msgbox.setLeftName("确定");
				msgbox.setRightName("取消");
				msgbox.addLeftTLV(new ClearDataTLV());
				msgbox.addLeftTLV(new SendDataTLV(MmochatConstant
						.getClientModuleId(), MmochatMain.getModuleInstID(),
						MmochatConstant.MSGCODE_MMOCHAT_C_13_11, (int) me
								.getRoleId()));
				ShowWaitingMsgBoxTLV wait = new ShowWaitingMsgBoxTLV();
				wait.setShowCancel(false);
				msgbox.addLeftTLV(wait);
				return MmochatUtil.tlvResponse(req.getHallState(), msgbox);
			}
			case 升级神行法宝: {
				CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
				String msg = "请将需要升级的神行法宝设置为使用中(打开包裹,点击使用)。您已经准备好了么?";
				msgbox.setContent(new Text(msg));
				msgbox.setLeftName("确定");
				msgbox.setRightName("取消");
				msgbox.addLeftTLV(new ClearDataTLV());
				msgbox.addLeftTLV(new SendDataTLV(MmochatConstant
						.getClientModuleId(), MmochatMain.getModuleInstID(),
						MmochatConstant.MSGCODE_MMOCHAT_C_13_12, (int) me
								.getRoleId()));
				ShowWaitingMsgBoxTLV wait = new ShowWaitingMsgBoxTLV();
				wait.setShowCancel(false);
				msgbox.addLeftTLV(wait);
				return MmochatUtil.tlvResponse(req.getHallState(), msgbox);
			}
			case 法宝升级说明: {
				CreateTlvWin tlv = new CreateTlvWin();
				tlv.setWinType(WinType.Text);
				tlv.setRightName("返回");
				tlv.setTitle(type.toString());
				tlv.setWinHeight(188);
				tlv.addRightTLV(new CloseWinTLV());
				String content = MmochatUtil.wrapColor("[概述]", Color.green);
				content += "\n神行法宝最高8级。当灵气达到升级条件时可以找多宝道人进行升级。";
				int attrValue[] = new int[] { 0, 0, 0, 6, 10, 14, 18, 20 };
				for (int i = 1; i <= 8; i++) {
					content += "\n\n"
							+ MmochatUtil.wrapColor("[" + i + "级法宝]\n",
									Color.green);
					int flyMachineSpeedLevel = i > 3 ? 3 : i;
					int flyMachineFlyLevel = i < 3 ? 0 : (i - 3);
					String title = MmochatCommonObject
							.getFlyMachineName(flyMachineSpeedLevel);
					if (flyMachineSpeedLevel == 3 && flyMachineFlyLevel == 5) {
						title += "(飞行形态)";
					}
					content += MmochatUtil.wrapColor(title, Color.yellow)
							+ "\n";
					content += "移动：" + flyMachineSpeedLevel + "阶\n";
					content += "腾空：" + flyMachineFlyLevel + "阶\n";
					content += "消耗：每小时"
							+ MmochatCommonObject.getFlyMachineUsePerHour(
									flyMachineSpeedLevel, flyMachineFlyLevel)
							+ "体力\n";
					content += "升级灵气："
							+ MmochatCommonObject.getFlyMachineUplevelNeed(
									flyMachineSpeedLevel, flyMachineFlyLevel)
							+ "\n";
					Color attrColor = Color.cyan;
					switch (flyMachineSpeedLevel) {
					case 1:
						content += MmochatUtil.wrapColor("行走速度+28%", attrColor);
						break;
					case 2:
						content += MmochatUtil.wrapColor("行走速度+43%", attrColor);
						break;
					case 3:
						content += MmochatUtil.wrapColor("行走速度+57%", attrColor);
						break;
					default:
						break;
					}
					if (attrValue[i - 1] > 0) {
						content += "\n"
								+ MmochatUtil.wrapColor("全属性+"
										+ attrValue[i - 1], attrColor);
					}
				}
				tlv.setContent(new Text(content));
				return MmochatUtil.tlvResponse(req.getHallState(), tlv);
			}
			case 法宝体力消耗说明: {
				CreateTlvWin tlv = new CreateTlvWin();
				tlv.setWinType(WinType.Text);
				tlv.setRightName("返回");
				tlv.setTitle("体力消耗说明");
				tlv.setWinHeight(188);
				tlv.addRightTLV(new CloseWinTLV());
				String content = MmochatUtil.wrapColor("[体力作用]", Color.green);
				content += "\n神行法宝需要有足够的体力才能激活加速等功能。如果体力为0时，"
						+ "神行法宝加速移动功能将暂时消失。\n\n";
				content += MmochatUtil.wrapColor("[体力消耗]", Color.green);
				content += "不同等级的神行法宝每小时消耗的体力不同，一般等级越高，消耗越少，"
						+ "具体请查看<法宝升级说明>。"
						+ MmochatUtil.wrapColor("体力消耗时间是按自然时间计算的，所以未使用法宝，"
								+ "或者离线时，法宝都会随着时间流逝而消耗体力。\n\n", Color.yellow);
				content += MmochatUtil.wrapColor("[体力补充]", Color.green);
				content += "在主界面按9键打开商城，进入法宝道具，里面有出售补充神行法宝体力的道具。"
						+ "注意，必需先将法宝设置为使用中，才能对其进行体力补充。";
				tlv.setContent(new Text(content));
				return MmochatUtil.tlvResponse(req.getHallState(), tlv);
			}
			case 法宝灵气增长说明: {
				CreateTlvWin tlv = new CreateTlvWin();
				tlv.setWinType(WinType.Text);
				tlv.setRightName("返回");
				tlv.setTitle("灵气增长说明");
				tlv.setWinHeight(188);
				tlv.addRightTLV(new CloseWinTLV());
				String content = MmochatUtil.wrapColor("[灵气作用]", Color.green);
				content += "神行法宝需要达到一定灵气要求，才能进行升级。\n\n";
				content += MmochatUtil.wrapColor("[灵气增长]", Color.green);
				content += "在线每5分钟获得1点灵气，离线每30分钟获得1点灵气。"
						+ MmochatUtil.wrapColor("本次在线获得的灵气，在下次上线时增加",
								Color.yellow) + "，离线期间的灵气，也在上线时增加。只有上线时"
						+ MmochatUtil.wrapColor("已装备使用", Color.yellow)
						+ "的神行法宝才能获得此前的灵气增长，每次上线最多获得200点灵气增长。\n\n";
				content += MmochatUtil.wrapColor("[快速增长]", Color.green);
				content += "在主界面按9键打开商城，进入法宝道具，里面有出售快速增加神行法宝灵气的道具。";
				tlv.setContent(new Text(content));
				return MmochatUtil.tlvResponse(req.getHallState(), tlv);
			}
			case 高人指点: {
				int minLevel = 40, maxLevel = MmochatConstant.maxLevel;
				int minTeamerNum = 2;
				int equipLevel;
				int expectTeamNum = 3;
				double bossPhysicalAttack = 0, bossPhysicalAttackPercent = 0, bossMagicAttack = 0, bossMagicAttackPercent = 0;
				double monsterPhysicalAttack = 0, monsterPhysicalAttackPercent = 0, monsterMagicAttack = 0, monsterMagicAttackPercent = 0;
				int bossSuperPhysicalAttack = 0, bossSuperSpritAttack = 0;
				int monsterSuperPhysicalAttack = 0, monsterSuperSpritAttack = 0;
				int bossMagicAttackNum = 3;
				MmochatTaskType taskType = MmochatTaskType.高人指点;
				int myLevel = me.getLevel();

				if (myLevel < 80) {
					bossPhysicalAttack = 0.4;
					bossMagicAttack = 0.3;
					bossPhysicalAttackPercent = 0.75;
					bossMagicAttackPercent = 0.25;
					bossMagicAttackNum = 4;
					bossSuperPhysicalAttack = 10;
					bossSuperSpritAttack = 10;
					monsterPhysicalAttack = 0.2;
					monsterMagicAttack = 0.15;
					monsterPhysicalAttackPercent = 1;
					monsterMagicAttackPercent = 0;
					monsterSuperPhysicalAttack = 5;
					monsterSuperSpritAttack = 5;
					equipLevel = 4;
				} else {
					bossPhysicalAttack = 0.4;
					bossMagicAttack = 0.3;
					bossPhysicalAttackPercent = 0.75;
					bossMagicAttackPercent = 0.25;
					bossMagicAttackNum = 5;
					bossSuperPhysicalAttack = 10;
					bossSuperSpritAttack = 10;
					monsterPhysicalAttack = 0.2;
					monsterMagicAttack = 0.15;
					monsterPhysicalAttackPercent = 1;
					monsterMagicAttackPercent = 0;
					monsterSuperPhysicalAttack = 5;
					monsterSuperSpritAttack = 5;
					equipLevel = 6;
				}

				// 领取条件判断:等级，人数，有未完成任务
				MmochatTask myTask = me.getTaskByType(taskType);
				if (myTask != null
						&& myTask.getTaskState() == MmochatTaskStateType.已接) {
					// 任务超时检测
					if (myTask.isInvalid()) {
						me.getTasks().remove(myTask.getTaskId());
						// 下发删除任务
						Mmochat_4_12S taskPack = new Mmochat_4_12S();
						taskPack.setTaskId(myTask.getTaskId());
						MmochatUtil.sendCommonPack(me, taskPack);

						myTask = null;
					} else {
						return MmochatUtil.msgbox(req.getHallState(),
								"你已经领取了此任务,请先完成再来领取新任务!");
					}
				}

				List<MmochatPlayer> teamers = new ArrayList<MmochatPlayer>();
				if (me.isInTeam()) {
					MmochatTeam team = MmochatTeamService.teams.get(me
							.getTeamId());
					if (team == null) {
						me.leaveTeam();
						teamers.add(me);
					} else {
						for (Integer roleId : team.getMemberId().values()) {
							MmochatPlayer member = MmochatMainService.players
									.get(roleId);
							if (member != null) {
								teamers.add(member);
							}
						}
					}
				} else {
					teamers.add(me);
				}
				if (teamers.size() < minTeamerNum) {
					return MmochatUtil.msgbox(req.getHallState(), "此行凶险,请至少"
							+ minTeamerNum + "人同行!");
				}
				// 扣除战绩
				int needZhangji = myLevel;

				for (MmochatPlayer member : teamers) {
					if (member.getLevel() < minLevel) {
						if (member == me) {
							return MmochatUtil.msgbox(req.getHallState(),
									"你年岁尚轻,请" + minLevel + "级后再来找我!");
						} else {
							return MmochatUtil.msgbox(req.getHallState(), "队伍中"
									+ MmochatUtil.wrapColor(member.getName(),
											Color.yellow) + "年岁尚轻,还不能进行此修炼!");
						}
					}
					if (member.getZhanji() < needZhangji) {
						if (member == me) {
							return MmochatUtil.msgbox(req.getHallState(),
									"你的战绩不足" + needZhangji + "点，无法进行接受高人指点。");
						} else {
							return MmochatUtil.msgbox(req.getHallState(), "队伍中"
									+ MmochatUtil.wrapColor(member.getName(),
											Color.yellow) + "的战绩不足"
									+ needZhangji + "点，无法进行接受高人指点。");
						}
					}
				}
				if (me.getLevel() > maxLevel) {
					return MmochatUtil.msgbox(req.getHallState(),
							"你等级过高,无法领取此任务!");
				}
				// 获取轮次
				int turn;
				if (myTask == null) {
					// 第一次接此任务
					turn = 1;
				} else {
					turn = myTask.getTaskTurn();
				}
				// 任务在玩家身保持40分钟
				long lifeTime = 40 * MmochatConstant.MS_PER_MINUTE;
				// 任务在NPC身上保持60分钟，玩家在第40分时进入战斗，如果在20分钟内结束战斗则仍可获得奖励
				long npcTaskLiefTime = 60 * MmochatConstant.MS_PER_MINUTE;

				MmochatMap theMap = MmochatMapService.maps
						.get(MmochatConstant.mapId_西岐);
				if (theMap == null) {
					return MmochatUtil.msgbox(req.getHallState(),
							"暂时无法领取此任务，请联系GM!");
				}
				MmochatNpc tmpNpc = theMap.getRandomFixedNpc(npc.getNpcId());
				MmochatTempTask newTask = new MmochatTempTask(true);
				newTask.setAccept_time(System.currentTimeMillis());
				tmpNpc.addTask(newTask);
				newTask.setTaskName(type.toString());
				newTask.setTaskType(taskType);
				newTask.setTaskTurn(turn);
				newTask.setFinish_npcId(tmpNpc.getNpcId());
				newTask.setTaskLife(npcTaskLiefTime);
				String detail = "第"
						+ turn
						+ "轮:请到"
						+ MmochatUtil.wrapColor(theMap.getMapName() + "("
								+ tmpNpc.getX() + "," + tmpNpc.getY() + ")",
								Color.yellow)
						+ MmochatUtil.wrapColor("找", Color.white)
						+ MmochatUtil.wrapColor(tmpNpc.getName(), Color.green)
						+ "指点武艺。";
				String taskDetail = detail
						+ "(各类急急如律令、天尊令、驱兽令、系统双倍有效；接任务后40分钟内未完成则任务失败)";
				newTask.setTaskDetail(taskDetail);

				MmochatNpcBattle battle = new MmochatNpcBattle();
				newTask.setFinish_need_battles(battle);
				MmochatMonsterFactory boss = new MmochatMonsterFactory();
				boss.setLevelType(MmochatBossLevelType.队长等级);
				boss.setBmpType(tmpNpc.getBmpType());
				boss.setName(tmpNpc.getName());
				boss.setLevel(me.getTrueLevel());
				boss.setEquipLevel(equipLevel);
				boss.setTeamNum(expectTeamNum);
				boss.setKillRound(3);
				boss.setPhysical(bossPhysicalAttack);
				boss.setMagic(bossMagicAttack);
				boss.setSuperPhysicalAttack(bossSuperPhysicalAttack);
				boss.setSuperSpritAttack(bossSuperSpritAttack);
				boss.setBossMaxSkillTargetNum(bossMagicAttackNum);
				boss.setSpeedPointAddType(3);
				MmochatAttackModeOfNormal defaultAttackMode = new MmochatAttackModeOfNormal();
				defaultAttackMode
						.setPhysicalAttackOpportunity((int) (100 * bossPhysicalAttackPercent));
				defaultAttackMode
						.setMagicAttackOppotunity((int) (100 * bossMagicAttackPercent));
				defaultAttackMode
						.setLimitOppotunity((int) (100 * (1 - bossMagicAttackPercent - bossPhysicalAttackPercent)));
				boss.setAttackMode_normal(defaultAttackMode);

				boss.setDao((int) (boss.getDaoParam() * MmochatBattleService
						.getStandardDao(me.getLevel(), me.getLife_turn())));
				boss.setAntiConfuse(turn);
				boss.setAntiFreeze(turn);
				boss.setAntiSeal(turn);
				battle.setBoss(boss);

				// 道具:如果使用了满卡，则小怪数+大怪数量固定为2XteamNum,
				int teamNum = teamers.size();
				int monsterNum = 0;
				if (me.hasPropEffect(MmochatPropType.顶级急急如律令.getEffectKey())) {
					monsterNum = teamNum * 5;
				} else if (me.hasPropEffect(MmochatPropType.特级急急如律令
						.getEffectKey())) {
					monsterNum = (int) (teamNum * 3.4);
				} else if (me.hasPropEffect(MmochatPropType.超级急急如律令
						.getEffectKey())) {
					monsterNum = (int) (teamNum * 2.5);
				} else if (me.hasPropEffect(MmochatPropType.急急如律令
						.getEffectKey())) {
					monsterNum = teamNum * 2;
				} else {
					monsterNum = teamNum
							+ (int) (Math.random() * (teamNum + 1));
				}
				monsterNum = Math.min(10, monsterNum);
				monsterNum = monsterNum - 1;

				List<MmochatMonsterFactory> monsters = new ArrayList<MmochatMonsterFactory>();
				for (int i = 0; i < monsterNum; i++) {
					MmochatMonsterFactory monster = new MmochatMonsterFactory();
					monster.setLevelType(MmochatBossLevelType.队长等级);
					monster.setBmpType(tmpNpc.getBmpType());
					monster.setName("分身");
					monster.setLevel(me.getTrueLevel());
					monster.setEquipLevel(equipLevel);
					monster.setTeamNum(expectTeamNum);
					monster.setKillRound(1);
					monster.setPhysical(monsterPhysicalAttack);
					monster.setMagic(monsterMagicAttack);
					monster.setBossMaxSkillTargetNum(2);
					monster.setSuperPhysicalAttack(monsterSuperPhysicalAttack);
					monster.setSuperSpritAttack(monsterSuperSpritAttack);
					monster.setSpeedPointAddType(0);
					MmochatAttackModeOfNormal attackMode = new MmochatAttackModeOfNormal();
					attackMode
							.setPhysicalAttackOpportunity((int) (100 * monsterPhysicalAttackPercent));
					attackMode
							.setMagicAttackOppotunity((int) (100 * monsterMagicAttackPercent));
					attackMode.setLimitOppotunity(0);
					monster.setAttackMode_normal(attackMode);
					monster
							.setDao((int) (monster.getDaoParam() * MmochatBattleService
									.getStandardDao(me.getLevel(), me
											.getLife_turn())));
					monsters.add(monster);
				}
				battle.setSmallBoss(monsters);

				// 清除本队所有人的此类任务，复制并增加新的任务,并设置此任务为<已接>
				for (MmochatPlayer member : teamers) {
					MmochatTask t = member.getTaskByType(taskType);
					if (t != null) {
						member.getTasks().remove(t.getTaskId());
						// 下发删除任务
						Mmochat_4_12S taskPack = new Mmochat_4_12S();
						taskPack.setTaskId(t.getTaskId());
						MmochatUtil.sendCommonPack(member, taskPack);
					}
					MmochatTempTask tmpTask = newTask.getClone();
					tmpTask.setTaskState(MmochatTaskStateType.已接);
					tmpTask.setTaskLife(lifeTime);
					member.addTask(tmpTask);
					member.addZhanji(-1 * needZhangji);

					// 下发增加任务
					Mmochat_4_11S pack = new Mmochat_4_11S();
					pack.setActionType(0);
					pack.setMe(me);
					pack.setTask(tmpTask);
					MmochatUtil.sendCommonPack(member, pack);

					// 更新NPC任务标志
					Mmochat_4_14S npcPack = new Mmochat_4_14S();
					npcPack.setMe(me);
					npcPack.addNpc(tmpNpc);
					MmochatUtil.sendCommonPack(me, npcPack);

					String msgInfo = detail + "(消耗" + needZhangji + "点战绩)";
					if (MmochatTeamService.getTeamState(member) == MmochatTeamStateType.队员) {
						MmochatUtil.sendCommonMsgbox(member, msgInfo);
					} else {
						CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
						msgbox.setContent(new Text(msgInfo));
						msgbox.setLeftName("确定");
						msgbox.addLeftTLV(new CallLocalFuncTlv(
								MmochatConstant.funcode_worldPathFunc, tmpNpc
										.getMapId(), tmpNpc.getX(), tmpNpc
										.getY()));

						CtrlTLVStructureRequest tracePack = MmochatUtil
								.tlvResponseWithoutHallState(msgbox);
						MmochatUtil.sendCommonPack(member, tracePack);
					}
				}
				break;
			}
			case 真假情报: {
				int minLevel = 70, maxLevel = MmochatConstant.maxLevel;
				int minTeamerNum = 1;
				MmochatTaskType taskType = MmochatTaskType.真假情报;

				// 领取条件判断:等级，人数，有未完成任务
				MmochatTask myTask = me.getTaskByType(taskType);
				if (myTask != null
						&& myTask.getTaskState() == MmochatTaskStateType.已接) {
					// 任务超时检测
					if (myTask.isInvalid()) {
						me.getTasks().remove(myTask.getTaskId());
						// 下发删除任务
						Mmochat_4_12S taskPack = new Mmochat_4_12S();
						taskPack.setTaskId(myTask.getTaskId());
						MmochatUtil.sendCommonPack(me, taskPack);

						myTask = null;
					} else {
						return MmochatUtil.msgbox(req.getHallState(),
								"你已经领取了此任务,请先完成再来领取新任务!");
					}
				}

				List<MmochatPlayer> teamers = MmochatTeamService
						.getMyTeamMember(me);
				if (teamers.size() < minTeamerNum) {
					return MmochatUtil.msgbox(req.getHallState(), "此行凶险,请至少"
							+ minTeamerNum + "人同行!");
				}

				for (MmochatPlayer member : teamers) {
					if (member.getLevel() < minLevel) {
						if (member == me) {
							return MmochatUtil.msgbox(req.getHallState(),
									"你年岁尚轻,请" + minLevel + "级后再来找我!");
						} else {
							return MmochatUtil.msgbox(req.getHallState(), "队伍中"
									+ MmochatUtil.wrapColor(member.getName(),
											Color.yellow) + "年岁尚轻,还不能进行此修炼!");
						}
					} else if (member.getLevel() > maxLevel) {
						if (member == me) {
							return MmochatUtil.msgbox(req.getHallState(),
									"你等级过高，无法领取此任务!");
						} else {
							return MmochatUtil.msgbox(req.getHallState(), "队伍中"
									+ MmochatUtil.wrapColor(member.getName(),
											Color.yellow) + "等级过高，无法参与此任务!");
						}
					}
				}
				// 获取轮次
				int turn;
				if (myTask == null) {
					// 第一次接此任务
					turn = 1;
				} else {
					turn = myTask.getTaskTurn();
				}
				// 任务在玩家身保持40分钟
				long lifeTime = 40 * MmochatConstant.MS_PER_MINUTE;

				// 生成任务地点
				int[] maps = new int[] { 19, 20, 13, 8, 14, 9, 16, 3 };
				int index = MmochatUtil.getRandomValue(maps.length);
				int mapId = maps[index];
				MmochatPoint point = MmochatMapService
						.getRandReachablePoint(mapId);
				MmochatMap map = MmochatMapService.getMapByMapId(mapId);
				if (map == null) {
					log.error("真假情报生成一个未知地点：mapId=" + mapId);
					return MmochatUtil.msgbox(req.getHallState(), "服务器忙，请稍候再试");
				}
				short x1 = (short) (point.getX() * 24 + Math.random() * 24);
				short y1 = (short) (point.getY() * 24 + Math.random() * 24);

				// 生成任务
				MmochatTempTask newTask = new MmochatTempTask(true);
				newTask.setAccept_time(System.currentTimeMillis());
				newTask.setTaskName(type.toString());
				newTask.setTaskType(taskType);
				newTask.setTaskTurn(turn);
				newTask.setTaskLife(lifeTime);
				newTask.setTargetMapId(mapId);
				newTask.setTargetX(x1);
				newTask.setTargetY(y1);
				String detail = "第"
						+ turn
						+ "轮:"
						+ "老夫今日隐隐感应到"
						+ MmochatUtil.wrapColor(map.getMapName() + "(" + x1
								+ "," + y1 + ")", Color.yellow)
						+ "有妖气出现，不知是真是假。你们先去查探一下，到了那里使用"
						+ MmochatUtil.wrapColor("照妖镜", Color.magenta)
						+ "一照，妖怪便会现形。";
				String taskDetail = detail
						+ MmochatUtil.wrapColor("\n(天尊令、驱兽令、各类急急如律令、系统双倍有效；"
								+ "接任务后40分钟内未完成则任务失败；照妖镜商城有售；有10%机率接到假情报，"
								+ "假情报不会触发战斗，直接完成任务并获得战绩奖励，如果是真情报，则触发战斗，"
								+ "战斗胜利后获得大量经验奖励。)", Color.green);
				newTask.setTaskDetail(taskDetail);

				Date now = new Date();
				MmochatPackageGrid prop = me
						.getPropGridFromPackage(MmochatPropType.飞羽);

				// 清除本队所有人的此类任务，复制并增加新的任务,并设置此任务为<已接>
				for (MmochatPlayer member : teamers) {
					MmochatTask t = member.getTaskByType(taskType);
					if (t != null) {
						member.getTasks().remove(t.getTaskId());
						// 下发删除任务
						Mmochat_4_12S taskPack = new Mmochat_4_12S();
						taskPack.setTaskId(t.getTaskId());
						MmochatUtil.sendCommonPack(member, taskPack);
					}
					MmochatTempTask tmpTask = newTask.getClone();
					tmpTask.setTaskState(MmochatTaskStateType.已接);
					member.addTask(tmpTask);

					// 下发增加任务
					Mmochat_4_11S pack = new Mmochat_4_11S();
					pack.setActionType(0);
					pack.setMe(me);
					pack.setTask(tmpTask);
					MmochatUtil.sendCommonPack(member, pack);

					if (member != me) {
						MmochatUtil.sendCommonMsgbox(member, detail);
					} else {
						if (prop == null
								|| (now.getDay() != 0 && now.getDay() != 6)) {
							CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
							msgbox.setContent(new Text(detail));
							msgbox.setLeftName("确定");
							msgbox
									.addLeftTLV(new CallLocalFuncTlv(
											MmochatConstant.funcode_worldPathFunc,
											newTask.getTargetMapId(), newTask
													.getTargetX(), newTask
													.getTargetY()));

							CtrlTLVStructureRequest tracePack = MmochatUtil
									.tlvResponseWithoutHallState(msgbox);
							MmochatUtil.sendCommonPack(member, tracePack);
						} else {
							// 有飞羽，询问是否直接飞去
							detail += "!\n"
									+ MmochatUtil.wrapIcon(MmochatPropType.飞羽
											.getBmpId())
									+ MmochatUtil.wrapColor("是否使用飞羽直达目的地?",
											Color.red);
							CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
							msgbox.setContent(new Text(detail));
							msgbox.setLeftName("使用");
							msgbox.setRightName("取消");
							msgbox
									.addRightTLV(new CallLocalFuncTlv(
											MmochatConstant.funcode_worldPathFunc,
											newTask.getTargetMapId(), newTask
													.getTargetX(), newTask
													.getTargetY()));

							msgbox.addLeftTLV(new ClearDataTLV());
							msgbox.addLeftTLV(new AddDataTLV((int) mapId));
							msgbox.addLeftTLV(new AddDataTLV((int) x1));
							msgbox.addLeftTLV(new AddDataTLV((int) y1));
							msgbox.addLeftTLV(new SendDataTLV(MmochatConstant
									.getClientModuleId(), MmochatMain
									.getModuleInstID(),
									MmochatConstant.MSGCODE_MMOCHAT_C_9_62,
									(int) me.getRoleId()));
							ShowWaitingMsgBoxTLV wait = new ShowWaitingMsgBoxTLV();
							wait.setShowCancel(false);
							msgbox.addLeftTLV(wait);

							CtrlTLVStructureRequest msgboxPack = MmochatUtil
									.tlvResponseWithoutHallState(msgbox);
							MmochatUtil.sendCommonPack(member, msgboxPack);
						}
					}
				}

				break;
			}
			case 推荐人介绍: {
				CreateTlvWin tlv = new CreateTlvWin();
				tlv.setWinType(WinType.Text);
				tlv.setRightName("返回");
				tlv.setTitle(type.toString());
				tlv.setWinHeight(188);
				tlv.addRightTLV(new CloseWinTLV());
				String content = MmochatUtil
						.wrapColor("[推荐人的奖励]", Color.yellow);
				content += "\n您推荐的玩家在游戏内第一个月充值的20%金额"
						+ "及第二个月充值的10%金额将转化为您的积分奖励。积分可以兑换元宝。\n\n";
				content += MmochatUtil.wrapColor("[怎么成为推荐人]", Color.yellow);
				content += "\n您已经是推荐人了，请查看<我的推荐信息>，里面有您的推荐人账号。\n\n";
				content += MmochatUtil.wrapColor("[怎么推荐]", Color.yellow);
				content += "\n通过好友聊天、论坛、群聊天等各种方式让其它朋友来玩这个游戏("
						+ MmochatUtil.wrapColor("任何一个区服", Color.red) + ")，"
						+ "请他们创建角色时将推荐人这项填写为您的推荐人账号就可以了。";
				content += MmochatUtil.wrapColor("您的朋友填写了推荐人，也会额外获得系统赠送的丰厚的奖励"
						+ "(5个天尊令和1个神行法宝残片)。", Color.green);
				content += "赶快叫上你的朋友们一起来玩吧!";

				tlv.setContent(new Text(content));

				return MmochatUtil.tlvResponse(req.getHallState(), tlv);
			}
			case 我的推荐信息: {
				Integer serverId = MmochatMain.getThisServerId();
				if (serverId == null) {
					return MmochatUtil.msgbox(req.getHallState(),
							"数据尚未准备好，请过几分钟再试!");
				}
				CreateTlvWin tlv = new CreateTlvWin();
				tlv.setWinType(WinType.Text);
				tlv.setRightName("返回");
				tlv.setTitle(type.toString());
				tlv.setWinHeight(188);
				tlv.addRightTLV(new CloseWinTLV());
				String content = MmochatUtil.wrapColor("[我的推荐人账号]",
						Color.yellow);
				content += "\n" + serverId + "区" + me.getName();
				content += "\n\n"
						+ MmochatUtil.wrapColor("[我的推荐人积分]", Color.yellow);
				content += "\n" + me.getSuggestScore();
				content += "\n\n";
				content += MmochatUtil.wrapColor(
						"请注意：如果您使用江湖名号更改了角色名,那么您的推荐人账号" + "也会随之更改。",
						Color.green);

				tlv.setContent(new Text(content));

				return MmochatUtil.tlvResponse(req.getHallState(), tlv);
			}
			case 积分兑换元宝: {
				CreateTlvWin tlv = getSuggestScore2BigMoneyTlv(me);
				return MmochatUtil.tlvResponse(req.getHallState(), tlv);
			}
			case 领取奖券: {
				Date now = new Date();
				Date lastDate = new Date(me.getLastLotteryTime());

				if (now.getDate() == lastDate.getDate()
						&& now.getMonth() == lastDate.getMonth()
						&& now.getYear() == lastDate.getYear()) {
					// 今天已经领取了奖券
					return MmochatUtil.msgbox(req.getHallState(),
							"您今天已经领取了奖券，每天只能领取一次噢，请明天再来吧!");
				}
				if (checkStorePwd(me)) {
					return null;
				}

				int lotteryBak = me.getLottery();
				int sustainedLotteryDaysBak = me.getSustainedLotteryDays();
				long lastLotteryTimeBak = me.getLastLotteryTime();
				int lotteryTemp;
				int sustainedLotteryDaysTemp;
				long lastLotteryTimeTemp;
				int lotteryReceived;

				lastDate.setHours(0);
				lastDate.setMinutes(0);
				lastDate.setSeconds(0);

				// 连续领奖中
				if ((now.getTime() - lastDate.getTime()) < (MmochatConstant.MS_PER_DAY * 2)) {
					lastLotteryTimeTemp = now.getTime();
					sustainedLotteryDaysTemp = sustainedLotteryDaysBak + 1;
					lotteryReceived = Math
							.min(sustainedLotteryDaysTemp * 5, 40);
					if (isTodayJianQuanDoubleAward()) {
						lotteryReceived *= 2;
					}
					lotteryTemp = lotteryBak + lotteryReceived;
				}
				// 隔天领奖
				else {
					lastLotteryTimeTemp = now.getTime();
					sustainedLotteryDaysTemp = 1;
					lotteryReceived = 5;
					if (isTodayJianQuanDoubleAward()) {
						lotteryReceived *= 2;
					}
					lotteryTemp = lotteryBak + lotteryReceived;
				}

				me.setLottery(lotteryTemp);
				me.setSustainedLotteryDays(sustainedLotteryDaysTemp);
				me.setLastLotteryTime(lastLotteryTimeTemp);
				int dao = 0;
				if (me.getStore_pwd_state() != MmochatStorePwdState.未设置钱庄密码) {
					dao = MmochatUtil.getRandomValue(100, 300);
					// 刷道比赛
					MmochatPropService.dealDaoActivity(me, dao);

					me.addDao(dao);
				}

				try {
					MmochatDao.updateRoleLottery(me);
				} catch (Exception e) {
					e.printStackTrace();
					me.setLottery(lotteryBak);
					me.addDao(-1 * dao);
					me.setSustainedLotteryDays(sustainedLotteryDaysBak);
					me.setLastLotteryTime(lastLotteryTimeBak);
					return MmochatUtil
							.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
				}

				int exceptationOfLottery = Math.min((me
						.getSustainedLotteryDays() + 1) * 5, 40);
				String info;
				info = "您领取了"
						+ MmochatUtil.wrapColor(lotteryReceived, Color.green)
						+ "张奖券";
				if (me.getStore_pwd_state() != MmochatStorePwdState.未设置钱庄密码) {
					info += "，" + MmochatUtil.wrapColor(dao, Color.yellow)
							+ "天道行";
				} else {
					info += MmochatUtil.wrapColor("(设置钱庄密码后每天可多领取100~300天道行)",
							Color.red);
				}
				if (isTodayJianQuanDoubleAward()) {
					info += MmochatUtil.wrapColor("(双倍奖券)", Color.yellow);
					info += "!明天您将可以领取更多的奖券。祝您游戏愉快~";
				} else {
					info += "!明天您将可以领取"
							+ MmochatUtil.wrapColor(exceptationOfLottery,
									Color.green) + "张奖券。祝您游戏愉快~";
				}

				return MmochatUtil.msgbox(req.getHallState(), info);
			}
			case 查看奖券信息: {
				Date now = new Date();
				Date lastDate = new Date(me.getLastLotteryTime());
				String info;

				info = MmochatUtil.wrapColor("您当前的奖券总数:\n", Color.yellow);
				info += me.getLottery();
				info += "\n\n";
				info += MmochatUtil.wrapColor("提示:\n", Color.yellow);

				// 今日已领取奖券
				if (now.getDate() == lastDate.getDate()
						&& now.getMonth() == lastDate.getMonth()
						&& now.getYear() == lastDate.getYear()) {
					int exceptationOfLottery = Math.min((me
							.getSustainedLotteryDays() + 1) * 5, 40);
					info += "您已领取了今日的奖券,明天继续登录可领取" + exceptationOfLottery
							+ "张奖券!\n";
				}
				// 今日未领取奖券
				else {
					info += "您今日还未领取奖券,快点领取吧!\n";
				}

				info += "\n";
				info += MmochatUtil.wrapColor("领取奖券规则:\n", Color.yellow);
				info += "第一天可领取5张奖券,第二天继续登录可领取10张,第三天继续登录可领取15张,...,连续8天及以上登录可领取40张!\n";
				info += "如中断连续领取,则将重新从5张奖券开始。";

				CreateTlvWin tlv = new CreateTlvWin();
				tlv.setWinType(WinType.Text);
				tlv.setRightName("返回");
				tlv.setTitle("奖券信息");
				tlv.setWinHeight(188);
				tlv.addRightTLV(new CloseWinTLV());
				tlv.setContent(new Text(info));

				return MmochatUtil.tlvResponse(req.getHallState(), tlv);
			}
			case 抽奖: {
				CreateTlvWin tlv = new CreateTlvWin();
				tlv.setWinType(WinType.List);
				tlv.setLeftName("确定");
				tlv.setRightName("返回");
				tlv.setTitle(type.toString());
				tlv.setWinHeight(188);
				tlv.addRightTLV(new CloseWinTLV());

				tlv.addItemEvent("抽奖战斗道具", new ClearDataTLV(), new AddDataTLV(
						(int) 0));
				tlv.addItemEvent("抽奖特色道具", new ClearDataTLV(), new AddDataTLV(
						(int) 1));
				// tlv.addItemEvent("抽奖装备法宝", new ClearDataTLV(), new
				// AddDataTLV(
				// (int) 2));

				tlv.addLeftTLV(new SendDataTLV(MmochatConstant
						.getClientModuleId(), MmochatMain.getModuleInstID(),
						MmochatConstant.MSGCODE_MMOCHAT_C_13_20, (int) me
								.getRoleId()));
				tlv.addLeftTLV(new ShowWaitingMsgBoxTLV());

				return MmochatUtil.tlvResponse(req.getHallState(), tlv);
			}
			case 兑奖: {
				CreateTlvWin tlv = new CreateTlvWin();
				tlv.setWinType(WinType.List);
				tlv.setLeftName("确定");
				tlv.setRightName("返回");
				tlv.setTitle(type.toString());
				tlv.setWinHeight(188);
				tlv.addRightTLV(new CloseWinTLV());

				tlv.addItemEvent("兑换战斗道具", new ClearDataTLV(), new AddDataTLV(
						(int) 0));
				tlv.addItemEvent("兑换特色道具", new ClearDataTLV(), new AddDataTLV(
						(int) 1));
				// tlv.addItemEvent("兑换装备法宝", new ClearDataTLV(), new
				// AddDataTLV(
				// (int) 2));

				tlv.addLeftTLV(new SendDataTLV(MmochatConstant
						.getClientModuleId(), MmochatMain.getModuleInstID(),
						MmochatConstant.MSGCODE_MMOCHAT_C_13_18, (int) me
								.getRoleId()));
				tlv.addLeftTLV(new ShowWaitingMsgBoxTLV());

				return MmochatUtil.tlvResponse(req.getHallState(), tlv);
			}
			case 我们要结拜: {
				if (!me.isInTeam()) {
					return MmochatUtil.msgbox(req.getHallState(),
							"请和您想要结拜的朋友一起组队来我这里!可以2至5人结拜。");
				}
				if (MmochatTeamService.getTeamState(me) != MmochatTeamStateType.队长) {
					return MmochatUtil.msgbox(req.getHallState(),
							"请和您想要结拜的朋友一起组队来我这里!可以2至5人结拜。");
				}
				MmochatTeam team = MmochatTeamService.teams.get(me.getTeamId());
				if (team == null) {
					me.leaveTeam();
					return MmochatUtil.msgbox(req.getHallState(),
							"请和您想要结拜的朋友一起组队来我这里!可以2至5人结拜。");
				}
				if (team.getMemberId().size() < 2) {
					return MmochatUtil.msgbox(req.getHallState(),
							"请和您想要结拜的朋友一起组队来我这里!可以2至5人结拜。");
				}
				if (me.hasChenHaoType(MmochatChenHaoType.结拜称号)) {
					return MmochatUtil.msgbox(req.getHallState(),
							"您已经结拜过了，无法再次结拜!请先解除结拜。");
				}

				List<MmochatPlayer> members = new ArrayList<MmochatPlayer>();
				for (Integer roleId : team.getMemberId().values()) {
					MmochatPlayer member = MmochatMainService
							.getRoleFromBuffer(roleId);
					if (member == null) {
						return MmochatUtil.msgbox(req.getHallState(),
								"队伍中有成员掉线，请稍后再来!");
					}
					if (member.hasChenHaoType(MmochatChenHaoType.结拜称号)) {
						return MmochatUtil.msgbox(req.getHallState(), member
								.getName()
								+ "已经结拜过了，无法与你们再次结拜!");
					}
					members.add(member);
				}
				for (MmochatPlayer m1 : members) {
					for (MmochatPlayer m2 : members) {
						if (m1.getRoleId() != m2.getRoleId()) {
							MmochatFriend f1 = m1.getMyDearFriends().get(
									m2.getRoleId());
							if (f1 == null) {
								MmochatUtil.sendCommonMsgbox(m1, "您尚未添加"
										+ MmochatUtil.wrapColor(m2.getName(),
												Color.green) + "为好友，无法与其结拜!");
								if (me.getRoleId() != m1.getRoleId()) {
									return MmochatUtil.msgbox(req
											.getHallState(), MmochatUtil
											.wrapColor(m1.getName(),
													Color.green)
											+ "尚未添加"
											+ MmochatUtil.wrapColor(m2
													.getName(), Color.green)
											+ "为好友，不能结拜!");
								} else {
									return null;
								}
							}

							MmochatFriend f2 = m2.getMyDearFriends().get(
									m1.getRoleId());
							if (f2 == null) {
								MmochatUtil.sendCommonMsgbox(m2, "您尚未添加"
										+ MmochatUtil.wrapColor(m1.getName(),
												Color.green) + "为好友，无法与其结拜!");
								if (me.getRoleId() != m2.getRoleId()) {
									return MmochatUtil.msgbox(req
											.getHallState(), MmochatUtil
											.wrapColor(m2.getName(),
													Color.green)
											+ "尚未添加"
											+ MmochatUtil.wrapColor(m1
													.getName(), Color.green)
											+ "为好友，不能结拜!");
								} else {
									return null;
								}
							}

							if (f1.getFriendValue() < MmochatConstant.friendValueNeedToJieBai) {
								MmochatUtil
										.sendCommonMsgbox(
												m1,
												"您与"
														+ MmochatUtil
																.wrapColor(
																		m2
																				.getName(),
																		Color.green)
														+ "的好友度为"
														+ f1.getFriendValue()
														+ "点，好友度至少要"
														+ MmochatConstant.friendValueNeedToJieBai
														+ "点才能结拜!好友度可以通过组队打怪获得。");
								if (me.getRoleId() != m1.getRoleId()) {
									return MmochatUtil
											.msgbox(
													req.getHallState(),
													MmochatUtil.wrapColor(m1
															.getName(),
															Color.green)
															+ "与"
															+ MmochatUtil
																	.wrapColor(
																			m2
																					.getName(),
																			Color.green)
															+ "的好友度未达到"
															+ MmochatConstant.friendValueNeedToJieBai
															+ "点，不能结拜!");
								} else {
									return null;
								}
							}
							if (f2.getFriendValue() < MmochatConstant.friendValueNeedToJieBai) {
								MmochatUtil
										.sendCommonMsgbox(
												m2,
												"您与"
														+ MmochatUtil
																.wrapColor(
																		m1
																				.getName(),
																		Color.green)
														+ "的好友度为"
														+ f2.getFriendValue()
														+ "点，好友度至少要"
														+ MmochatConstant.friendValueNeedToJieBai
														+ "点才能结拜!好友度可以通过组队打怪获得。");
								if (me.getRoleId() != m2.getRoleId()) {
									return MmochatUtil
											.msgbox(
													req.getHallState(),
													MmochatUtil.wrapColor(m2
															.getName(),
															Color.green)
															+ "与"
															+ MmochatUtil
																	.wrapColor(
																			m1
																					.getName(),
																			Color.green)
															+ "的好友度未达到"
															+ MmochatConstant.friendValueNeedToJieBai
															+ "点，不能结拜!");
								} else {
									return null;
								}
							}
						}
					}
				}

				String word = "";
				switch (members.size()) {
				case 2:
					word = "双";
					break;
				case 3:
					word = "三";
					break;
				case 4:
					word = "四";
					break;
				case 5:
					word = "五";
					break;
				default:
					return MmochatUtil.msgbox(req.getHallState(),
							"请和您想要结拜的朋友一起组队来我这里!可以2至5人结拜。");
				}
				String editHint = "请输入你们"
						+ members.size()
						+ "人的个性结拜称号。"
						+ members.size()
						+ "人的结拜称号要求是:"
						+ MmochatUtil.wrapColor("4个字，且第3个字必须是<" + word + ">",
								Color.yellow)
						+ "，结拜需要扣除队长"
						+ MmochatUtil
								.getColorMoney(MmochatConstant.moneyCostToJieBai)
						+ "文钱!";
				CreateEditBoxTLV edit = new CreateEditBoxTLV();
				edit.setTitle(editHint);
				edit.setLeftName("确定");
				edit.setRightName("取消");
				edit.setContentLenMax(4);
				edit.setBoxType(CreateEditBoxTLV.TYPE_MSGBOX);
				edit.setInputType(CreateEditBoxTLV.INPUT_ANY << 4);
				edit.addLeftTLV(new ClearDataTLV());
				edit.addLeftTLV(new AddDataTLV((int) me.getRoleId()));
				edit.addLeftTLV(new AddEditBoxTLV());
				edit.addLeftTLV(new SendDataTLV(MmochatConstant
						.getClientModuleId(), MmochatMain.getModuleInstID(),
						MmochatConstant.MSGCODE_MMOCHAT_C_9_48, null));
				ShowWaitingMsgBoxTLV wait = new ShowWaitingMsgBoxTLV();
				wait.setShowCancel(false);
				edit.addLeftTLV(wait);

				return MmochatUtil.tlvResponse(req.getHallState(), edit);

			}
			case 取消结拜: {
				CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
				msgbox.setContent(new Text("取消结拜后，您的结拜称号将消失，其它结拜成员的结拜称号仍将保留。"
						+ "您确定要取消结拜么?"));
				msgbox.setLeftName("确定");
				msgbox.setRightName("取消");
				msgbox.addLeftTLV(new ClearDataTLV());
				msgbox.addLeftTLV(new AddDataTLV((int) me.getRoleId()));
				msgbox.addLeftTLV(new SendDataTLV(MmochatConstant
						.getClientModuleId(), MmochatMain.getModuleInstID(),
						MmochatConstant.MSGCODE_MMOCHAT_C_9_49, null));
				ShowWaitingMsgBoxTLV wait = new ShowWaitingMsgBoxTLV();
				wait.setShowCancel(false);
				msgbox.addLeftTLV(wait);
				return MmochatUtil.tlvResponse(req.getHallState(), msgbox);
			}
			case 我们要结婚: {
				if (!me.isInTeam()) {
					return MmochatUtil.msgbox(req.getHallState(),
							"请和您想要结婚的对象一起组队来我这里!只能两人组队噢。");
				}
				if (MmochatTeamService.getTeamState(me) != MmochatTeamStateType.队长) {
					return MmochatUtil.msgbox(req.getHallState(),
							"请和您想要结婚的对象一起组队来我这里!只能两人组队噢。");
				}
				MmochatTeam team = MmochatTeamService.teams.get(me.getTeamId());
				if (team == null) {
					me.leaveTeam();
					return MmochatUtil.msgbox(req.getHallState(),
							"请和您想要结婚的对象一起组队来我这里!只能两人组队噢。");
				}
				if (team.getMemberId().size() != 2) {
					return MmochatUtil.msgbox(req.getHallState(),
							"请组上您想要结婚的对象，只能两人组队噢，不要组上无关人员。");
				}
				MmochatPlayer he = null;
				for (Integer roleId : team.getMemberId().values()) {
					if (roleId != me.getRoleId()) {
						he = MmochatMainService.players.get(roleId);
						break;
					}
				}
				if (he == null) {
					return MmochatUtil.msgbox(req.getHallState(),
							"对方已掉线，请稍后再来!");
				}

				if (me.getWife_roleId() != -1) {
					return MmochatUtil.msgbox(req.getHallState(),
							"您已经有配偶了，不能再结婚了!");
				}
				if (he.getWife_roleId() != -1) {
					return MmochatUtil.msgbox(req.getHallState(),
							"对方已经有配偶了，不能再结婚了!");
				}
				if (me.getSexual() == he.getSexual()) {
					return MmochatUtil.msgbox(req.getHallState(),
							"根据婚姻法，同性不能结婚!");
				}
				MmochatFriend f1 = me.getMyDearFriends().get(he.getRoleId());
				if (f1 == null) {
					return MmochatUtil.msgbox(req.getHallState(),
							"对方还不是您的好友，不能结婚!");
				}
				MmochatFriend f2 = he.getMyDearFriends().get(me.getRoleId());
				if (f2 == null) {
					return MmochatUtil.msgbox(req.getHallState(),
							"对方还没有加您为好友，不能结婚!");
				}
				if (f1.getFriendValue() < MmochatConstant.friendValueNeedToMarry) {
					return MmochatUtil.msgbox(req.getHallState(), "您与对方的好友度为"
							+ f1.getFriendValue() + "点，好友度至少要"
							+ MmochatConstant.friendValueNeedToMarry
							+ "点才能结婚!好友度可以通过组队打怪获得。");
				}
				if (f2.getFriendValue() < MmochatConstant.friendValueNeedToMarry) {
					return MmochatUtil.msgbox(req.getHallState(), "对方与您的好友度为"
							+ f2.getFriendValue() + "点，好友度至少要"
							+ MmochatConstant.friendValueNeedToMarry
							+ "点才能结婚!好友度可以通过组队打怪获得。");
				}

				String msg = "您确定要与"
						+ MmochatUtil.wrapColor(he.getName(), Color.green)
						+ "结为夫妻么?办理结婚手续需要"
						+ MmochatUtil
								.getColorMoney(MmochatConstant.moneyCostToMarry)
						+ "文钱。";
				CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
				msgbox.setContent(new Text(msg));
				msgbox.setLeftName("确定");
				msgbox.setRightName("取消");
				msgbox.addLeftTLV(new ClearDataTLV());
				msgbox.addLeftTLV(new AddDataTLV((int) he.getRoleId()));
				msgbox.addLeftTLV(new SendDataTLV(MmochatConstant
						.getClientModuleId(), MmochatMain.getModuleInstID(),
						MmochatConstant.MSGCODE_MMOCHAT_C_9_14, (int) me
								.getRoleId()));
				return MmochatUtil.tlvResponseWithoutHallState(msgbox);
			}
			case 结婚说明: {
				String content = "";
				content += MmochatUtil.wrapColor("[结婚条件]", Color.yellow);
				content += "\n两个未婚、异性，且互相加为好友，双方的好友度都超过"
						+ MmochatUtil.wrapColor(
								MmochatConstant.friendValueNeedToMarry,
								Color.yellow)
						+ "点的公民，就可以到我这里申请结婚。结婚需要花费手续费"
						+ MmochatUtil
								.getColorMoney(MmochatConstant.moneyCostToMarry)
						+ "文钱\n\n";
				content += MmochatUtil.wrapColor("[结婚流程]", Color.yellow);
				content += "\n结婚双方组队前来，必需只有2人组队，即可到我这里申请结婚。"
						+ "我会询问双方的意愿，双方都愿意，那么我就会为你们办理结婚手续。\n\n";

				content += MmochatUtil.wrapColor("[好友度]", Color.yellow);
				content += "\n与好友组队进行打怪、刷道等活动时，每场战斗结束后都会增加1点好友度。"
						+ "如果未加对方为好友，则无法获得好友度。如果删除好友，那么与对方的好友度也会消失。";

				CreateTlvWin tlv = new CreateTlvWin();
				tlv.setWinType(WinType.Text);
				tlv.setRightName("返回");
				tlv.setTitle("结婚说明");
				tlv.setWinHeight(188);
				tlv.addRightTLV(new CloseWinTLV());
				tlv.setContent(new Text(content));

				return MmochatUtil.tlvResponse(req.getHallState(), tlv);
			}
			case 申请离婚: {
				if (!me.hasWife()) {
					return MmochatUtil.msgbox(req.getHallState(), "您还没有结婚!");
				}
				String msg = "您确定要与"
						+ MmochatUtil.wrapColor(me.getWife_name(), Color.green)
						+ "离婚么?";
				CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
				msgbox.setContent(new Text(msg));
				msgbox.setLeftName("离婚");
				msgbox.setRightName("取消");
				msgbox.addLeftTLV(new ClearDataTLV());
				msgbox.addLeftTLV(new SendDataTLV(MmochatConstant
						.getClientModuleId(), MmochatMain.getModuleInstID(),
						MmochatConstant.MSGCODE_MMOCHAT_C_9_16, (int) me
								.getRoleId()));
				return MmochatUtil.tlvResponse(req.getHallState(), msgbox);
			}
			case 增加好友度: {
				if (!me.isInTeam()) {
					return MmochatUtil.msgbox(req.getHallState(),
							"请和您想要提升好友度的的朋友一起组队来我这里!只能两人组队噢。");
				}
				if (MmochatTeamService.getTeamState(me) != MmochatTeamStateType.队长) {
					return MmochatUtil.msgbox(req.getHallState(),
							"请和您想要提升好友度的的朋友一起组队来我这里!只能两人组队噢。");
				}
				MmochatTeam team = MmochatTeamService.teams.get(me.getTeamId());
				if (team == null) {
					me.leaveTeam();
					return MmochatUtil.msgbox(req.getHallState(),
							"请和您想要提升好友度的的朋友一起组队来我这里!只能两人组队噢。");
				}
				if (team.getMemberId().size() != 2) {
					return MmochatUtil.msgbox(req.getHallState(),
							"只能两人组队噢，您的队伍人数太多了。");
				}
				MmochatPlayer he = null;
				for (Integer roleId : team.getMemberId().values()) {
					if (roleId != me.getRoleId()) {
						he = MmochatMainService.players.get(roleId);
						break;
					}
				}
				if (he == null) {
					return MmochatUtil.msgbox(req.getHallState(),
							"对方已掉线，请稍后再来!");
				}

				MmochatFriend f1 = me.getMyDearFriends().get(he.getRoleId());
				if (f1 == null) {
					return MmochatUtil.msgbox(req.getHallState(),
							"对方还不是您的好友，不能一起提升好友度!");
				}
				MmochatFriend f2 = he.getMyDearFriends().get(me.getRoleId());
				if (f2 == null) {
					return MmochatUtil.msgbox(req.getHallState(),
							"对方还没有加您为好友，不能一起提升好友度!");
				}

				String msg = "老夫可以瞬间提升你俩之间的好友度"
						+ MmochatUtil.wrapColor("100点", Color.yellow)
						+ "，但这需要耗费老夫不少的功力。如果你愿意给老夫"
						+ MmochatUtil.wrapColor("100元宝", Color.yellow)
						+ "用于救济苦命鸳鸯，老夫就帮你们一次。";
				CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
				msgbox.setContent(new Text(msg));
				msgbox.setLeftName("同意");
				msgbox.setRightName("取消");
				msgbox.addLeftTLV(new ClearDataTLV());
				msgbox.addLeftTLV(new AddDataTLV((int) he.getRoleId()));
				msgbox.addLeftTLV(new SendDataTLV(MmochatConstant
						.getClientModuleId(), MmochatMain.getModuleInstID(),
						MmochatConstant.MSGCODE_MMOCHAT_C_9_19, (int) me
								.getRoleId()));
				return MmochatUtil.tlvResponse(req.getHallState(), msgbox);
			}
			case 获得夫妻称号: {
				if (!me.hasWife()) {
					return MmochatUtil.msgbox(req.getHallState(), "您还没有配偶!");
				}
				if (me.getChenHaoMap().get(MmochatChenHaoType.娘子) != null
						|| me.getChenHaoMap().get(MmochatChenHaoType.相公) != null) {
					return MmochatUtil.msgbox(req.getHallState(), "您已经有夫妻称号了!");
				}
				if (me.getSexual() == 0) {
					// 男
					MmochatChenHao chenhao = new MmochatChenHao();
					chenhao.setType(MmochatChenHaoType.相公);
					chenhao.setName(me.getWife_name() + "的"
							+ chenhao.getType().toString());
					chenhao.setExtraEffectInfo("夫妻同心:与配偶组队时，气血增加10%");
					MmochatChenHao.addAndUpdateChenHaoAndSaveSql(
							me.getRoleId(), chenhao);
				} else {
					// 女
					MmochatChenHao chenhao = new MmochatChenHao();
					chenhao.setType(MmochatChenHaoType.娘子);
					chenhao.setName(me.getWife_name() + "的"
							+ chenhao.getType().toString());
					chenhao.setExtraEffectInfo("夫妻同心:与配偶组队时，气血增加10%");
					MmochatChenHao.addAndUpdateChenHaoAndSaveSql(
							me.getRoleId(), chenhao);
				}
				return MmochatUtil.msgbox(req.getHallState(), "您获得了夫妻称号!");
			}
			case 查看装备属性介绍: {
				CreateTlvWin tlv = new CreateTlvWin();
				tlv.setWinType(WinType.List);
				tlv.setLeftName("查看");
				tlv.setRightName("返回");
				tlv.setTitle("装备属性介绍");
				tlv.setWinHeight(208);
				tlv.addRightTLV(new CloseWinTLV());

				tlv.addItemEvent(MmochatEquipType.武器.getBmpId(), "武器",
						new ClearDataTLV(), new AddDataTLV(
								(int) MmochatEquipType.武器.getValue()));
				tlv.addItemEvent(MmochatEquipType.头盔.getBmpId(), "头盔",
						new ClearDataTLV(), new AddDataTLV(
								(int) MmochatEquipType.头盔.getValue()));
				tlv.addItemEvent(MmochatEquipType.衣服.getBmpId(), "衣服",
						new ClearDataTLV(), new AddDataTLV(
								(int) MmochatEquipType.衣服.getValue()));
				tlv.addItemEvent(MmochatEquipType.鞋子.getBmpId(), "鞋子",
						new ClearDataTLV(), new AddDataTLV(
								(int) MmochatEquipType.鞋子.getValue()));
				tlv.addItemEvent(MmochatEquipType.玉佩.getBmpId(), "玉佩",
						new ClearDataTLV(), new AddDataTLV(
								(int) MmochatEquipType.玉佩.getValue()));
				tlv.addItemEvent(MmochatEquipType.挂坠.getBmpId(), "挂坠",
						new ClearDataTLV(), new AddDataTLV(
								(int) MmochatEquipType.挂坠.getValue()));
				tlv.addItemEvent(MmochatEquipType.手镯.getBmpId(), "手镯",
						new ClearDataTLV(), new AddDataTLV(
								(int) MmochatEquipType.手镯.getValue()));

				tlv.addLeftTLV(new SendDataTLV(MmochatConstant
						.getClientModuleId(), MmochatMain.getModuleInstID(),
						MmochatConstant.MSGCODE_MMOCHAT_C_9_17, (int) me
								.getRoleId()));
				tlv.addLeftTLV(new ShowWaitingMsgBoxTLV());

				return MmochatUtil.tlvResponse(req.getHallState(), tlv);
			}
			case 转生装备属性查询: {
				if (me.getLife_turn() == 0) {
					return MmochatUtil.msgbox(req.getHallState(),
							"您尚未转生，暂无资格查询!");
				}
				CreateTlvWin tlv = new CreateTlvWin();
				tlv.setWinType(WinType.List);
				tlv.setLeftName("查看");
				tlv.setRightName("返回");
				tlv.setTitle("转生装备属性");
				tlv.setWinHeight(208);
				tlv.addRightTLV(new CloseWinTLV());

				tlv.addItemEvent(MmochatEquipType.武器.getBmpId(), "武器",
						new ClearDataTLV(), new AddDataTLV(
								(int) MmochatEquipType.武器.getValue()));
				tlv.addItemEvent(MmochatEquipType.头盔.getBmpId(), "头盔",
						new ClearDataTLV(), new AddDataTLV(
								(int) MmochatEquipType.头盔.getValue()));
				tlv.addItemEvent(MmochatEquipType.衣服.getBmpId(), "衣服",
						new ClearDataTLV(), new AddDataTLV(
								(int) MmochatEquipType.衣服.getValue()));
				tlv.addItemEvent(MmochatEquipType.鞋子.getBmpId(), "鞋子",
						new ClearDataTLV(), new AddDataTLV(
								(int) MmochatEquipType.鞋子.getValue()));

				tlv.addLeftTLV(new SendDataTLV(MmochatConstant
						.getClientModuleId(), MmochatMain.getModuleInstID(),
						MmochatConstant.MSGCODE_MMOCHAT_C_9_28, (int) me
								.getRoleId()));
				tlv.addLeftTLV(new ShowWaitingMsgBoxTLV());

				return MmochatUtil.tlvResponse(req.getHallState(), tlv);

			}
			case 领取新年礼物: {
				Date now = new Date();
				if (now.getMonth() == 0 && now.getDate() == 1) {
					if (MmochatTempActivityService.newYearMap.containsKey(me
							.getRoleId())) {
						return MmochatUtil.msgbox(req.getHallState(),
								"您已经领过新年礼物了!");
					} else {
						// 30级以上才能获得元宝、赠品道具
						if (me.getLevel() < 30) {
							return MmochatUtil.msgbox(req.getHallState(),
									"30级以上才能领取礼物噢，快去升级吧!");
						}
						if (!me.hasEnoughPackageSpace(1)) {
							return MmochatUtil.msgbox(req.getHallState(),
									"请先清理出1个包裹空位，用以接收礼物!");
						}
						if (MmochatTempActivityService.newYearMap
								.containsKey(me.getRoleId())) {
							return MmochatUtil.msgbox(req.getHallState(),
									"您已经领过新年礼物了!");
						}
						MmochatTempActivityService.newYearMap.put(me
								.getRoleId(), (byte) 0);

						MmochatPropType propType = null;
						int index = MmochatUtil.getRandomValue(4);
						switch (index) {
						case 0:
							propType = MmochatPropType.新年快乐o新;
							break;
						case 1:
							propType = MmochatPropType.新年快乐o年;
							break;
						case 2:
							propType = MmochatPropType.新年快乐o快;
							break;
						case 3:
						default:
							propType = MmochatPropType.新年快乐o乐;
							break;
						}

						MmochatProp prop = new MmochatProp(propType);
						prop.setCanDeal(false);
						me.addObjectToPackage(prop);

						try {
							MmochatDao.updateMyPackage(me);
						} catch (Exception e) {
							e.printStackTrace();
							me.delPackageObjById(prop.getId());
							return MmochatUtil.msgbox(req.getHallState(),
									"服务器忙，请稍候再试!");
						}
						String msg = MmochatUtil.wrapColor("恭喜，您获得了一个"
								+ MmochatUtil.wrapColor(propType.toString(),
										Color.magenta) + "，祝您新年快乐!",
								Color.yellow);
						MmochatChatService.sendSystemMsgToPerson(me, msg);
						return MmochatUtil.msgbox(req.getHallState(), msg);
					}
				} else {
					return MmochatUtil
							.msgbox(req.getHallState(), "1月1号才能领取礼包!");
				}

			}
			case 领取圣诞礼物: {
				Date now = new Date();
				if (now.getMonth() == 11 && now.getDate() == 25) {
					if (MmochatTempActivityService.chrismasMap.containsKey(me
							.getRoleId())) {
						return MmochatUtil.msgbox(req.getHallState(),
								"您已经领过圣诞节礼物了!");
					} else {
						// 30级以上才能获得元宝、赠品道具
						if (me.getLevel() < 30) {
							return MmochatUtil.msgbox(req.getHallState(),
									"30级以上才能领取礼物噢，快去升级吧!");
						}
						if (!me.hasEnoughPackageSpace(1)) {
							return MmochatUtil.msgbox(req.getHallState(),
									"请先清理出1个包裹空位，用以接收礼物!");
						}
						if (MmochatTempActivityService.chrismasMap
								.containsKey(me.getRoleId())) {
							return MmochatUtil.msgbox(req.getHallState(),
									"您已经领过圣诞节礼物了!");
						}
						MmochatTempActivityService.chrismasMap.put(me
								.getRoleId(), (byte) 0);

						MmochatPropType propType = MmochatPropType.圣诞礼物;

						MmochatProp prop = new MmochatProp(propType);
						prop.setCanDeal(false);
						me.addObjectToPackage(prop);

						try {
							MmochatDao.updateMyPackage(me);
						} catch (Exception e) {
							e.printStackTrace();
							me.delPackageObjById(prop.getId());
							return MmochatUtil.msgbox(req.getHallState(),
									"服务器忙，请稍候再试!");
						}
						String msg = MmochatUtil.wrapColor("圣诞快乐!您获得了一个"
								+ MmochatUtil.wrapColor("圣诞礼物", Color.magenta)
								+ "，祝您开心每一天!", Color.yellow);
						MmochatChatService.sendSystemMsgToPerson(me, msg);
						return MmochatUtil.msgbox(req.getHallState(), msg);
					}
				} else {
					return MmochatUtil.msgbox(req.getHallState(), "今天不是圣诞节!");
				}

			}
			case 感恩节礼包: {
				Date now = new Date();
				if (now.getMonth() == 10
						&& (now.getDate() == 24 || now.getDate() == 25)) {
					if (MmochatTempActivityService.thanksGivingMap
							.containsKey(me.getRoleId())) {
						return MmochatUtil.msgbox(req.getHallState(),
								"您已经领过感恩节礼物了!");
					} else {
						// 注册时间10天内：道行365天
						// 注册时间20天内：道行365天、1个随机道具
						// 注册时间30天内：道行365天、1个随机道具、3*等级（元宝）
						// 注册时间40天内：道行730天、2个随机道具、4*等级（元宝）
						// 注册时间50天内：道行730天、3个随机道具、5*等级（元宝）
						// 注册时间60天内：道行730天、4个随机道具、6*等级（元宝）
						// 注册时间60天上：道行730天、5个随机道具、7*等级（元宝）
						long regTime = System.currentTimeMillis()
								- me.getCreateTime();
						int day = (int) (regTime / MmochatConstant.MS_PER_DAY);
						int propNum = 0;
						int dao = 0;
						int bigMoney = 0;
						if (day <= 10) {
							propNum = 0;
							dao = 365;
							bigMoney = 0;
						} else if (day <= 20) {
							propNum = 1;
							dao = 365;
							bigMoney = 0;
						} else if (day <= 30) {
							propNum = 1;
							dao = 365;
							bigMoney = me.getLevel() * 3;
						} else if (day <= 40) {
							propNum = 2;
							dao = 730;
							bigMoney = me.getLevel() * 4;
						} else if (day <= 50) {
							propNum = 3;
							dao = 730;
							bigMoney = me.getLevel() * 5;
						} else if (day <= 60) {
							propNum = 4;
							dao = 730;
							bigMoney = me.getLevel() * 6;
						} else {
							propNum = 5;
							dao = 730;
							bigMoney = me.getLevel() * 7;
						}
						// 30级以上才能获得元宝、赠品道具
						if (me.getLevel() < 30) {
							propNum = 0;
							bigMoney = 0;
						}
						if (!me.hasEnoughPackageSpace(propNum)) {
							return MmochatUtil.msgbox(req.getHallState(),
									"请先清理出" + propNum + "个包裹空位，用以接收礼物!");
						}
						if (MmochatTempActivityService.thanksGivingMap
								.containsKey(me.getRoleId())) {
							return MmochatUtil.msgbox(req.getHallState(),
									"您已经领过感恩节礼物了!");
						}
						MmochatTempActivityService.thanksGivingMap.put(me
								.getRoleId(), (byte) 0);
						// 增加元宝、道具、道行
						String awardMsg = "";
						if (dao > 0) {
							me.addDao(dao);
							awardMsg += dao + "天道行、";
						}
						if (bigMoney > 0) {
							me.addBig_money(bigMoney);
							awardMsg += bigMoney + "元宝、";
						}
						Map<Integer, MmochatPackageGrid> packageBak = null;
						if (propNum > 0) {
							packageBak = (Map<Integer, MmochatPackageGrid>) MmochatUtil
									.deepClone(
											me.getMyPackage(),
											new TypeToken<Map<Integer, MmochatPackageGrid>>() {
											}.getType());

							MmochatPropType[] propList = null;
							propList = new MmochatPropType[] {
									MmochatPropType.锦囊, MmochatPropType.喇叭,
									MmochatPropType.成长丹, MmochatPropType.超级成长丹,
									MmochatPropType.轮回水, MmochatPropType.防冻剂,
									MmochatPropType.镇定剂, MmochatPropType.虚无水,
									MmochatPropType.迟滞水, MmochatPropType.八卦令,
									MmochatPropType.银联卡, MmochatPropType.赎罪牌,
									MmochatPropType.后悔药, MmochatPropType.混沌石,
									MmochatPropType.急急如律令, MmochatPropType.天尊令,
									MmochatPropType.道尊令, MmochatPropType.驱兽令,
									MmochatPropType.驭兽令, MmochatPropType.龙涎香,
									MmochatPropType.小血池, MmochatPropType.小法池,
									MmochatPropType.中法池, MmochatPropType.大法池,
									MmochatPropType.小血玲珑, MmochatPropType.小法玲珑,
									MmochatPropType.中法玲珑, MmochatPropType.大法玲珑,
									MmochatPropType.鬼灵珠, MmochatPropType.会员周卡 };

							for (int i = 0; i < propNum; i++) {
								int index = MmochatUtil
										.getRandomValue(propList.length);
								MmochatPropType propType = propList[index];
								MmochatProp prop = new MmochatProp(propType);
								prop.setCanDeal(false);
								boolean success = me.addObjectToPackage(prop);
								if (success) {
									awardMsg += propType.toString() + "、";
								}
							}
						}
						try {
							MmochatDao.updateRolePackage_BigMoney_Dao(me, dao,
									bigMoney);
						} catch (Exception e) {
							e.printStackTrace();
							if (packageBak != null) {
								me.setMyPackage(packageBak);
							}
							me.addDao(-1 * dao);
							me.addBig_money(-1 * bigMoney);
							return MmochatUtil.msgbox(req.getHallState(),
									"服务器忙，请稍候再试!");
						}
						String msg = MmochatUtil.wrapColor("感谢您" + day
								+ "天的相伴，我们给您送上"
								+ MmochatUtil.wrapColor(awardMsg, Color.green)
								+ "祝您开心每一天!仙剑问情，不能没有你!", Color.yellow);
						MmochatChatService.sendSystemMsgToPerson(me, msg);
						return MmochatUtil.msgbox(req.getHallState(), msg);
					}
				} else {
					return MmochatUtil.msgbox(req.getHallState(), "今天不是感恩节!");
				}
			}
			case 得道转生: {
				CreateTlvWin tlv = new CreateTlvWin();
				tlv.setWinType(WinType.List);
				tlv.setLeftName("确定");
				tlv.setRightName("返回");
				tlv.setTitle("得道转生");
				tlv.setWinHeight(188);
				tlv.addRightTLV(new CloseWinTLV());

				tlv.addItemEvent("转生说明", new ClearDataTLV(), new AddDataTLV(
						(int) 1));
				tlv.addItemEvent("我要转生", new ClearDataTLV(), new AddDataTLV(
						(int) 2));

				tlv.addLeftTLV(new SendDataTLV(MmochatConstant
						.getClientModuleId(), MmochatMain.getModuleInstID(),
						MmochatConstant.MSGCODE_MMOCHAT_C_9_21, (int) me
								.getRoleId()));
				tlv.addLeftTLV(new ShowWaitingMsgBoxTLV());

				return MmochatUtil.tlvResponse(req.getHallState(), tlv);

			}
			case 仙魔转换: {
				CreateTlvWin tlv = new CreateTlvWin();
				tlv.setWinType(WinType.Text);
				tlv.setRightName("返回");
				tlv.setTitle("仙魔转换");
				tlv.setWinHeight(188);
				tlv.addRightTLV(new CloseWinTLV());
				String content = "";
				if (me.getSecond_role_type() != MmochatSecondRoleType.未转生) {
					content += MmochatUtil
							.wrapColor("您当前为:"
									+ me.getSecond_role_type().toString(),
									Color.yellow);
				} else {
					content += MmochatUtil.wrapColor("您当前尚未转生，没有仙魔属性。",
							Color.yellow);
				}
				content += "\n\n";
				content += MmochatUtil.wrapColor("[转换条件]", Color.green);
				content += "\n转生后得到仙魔属性，可以进行仙魔转换。仙道可以转换为魔道，魔道也可以转换为仙道。"
						+ "每次转换需要扣除"
						+ MmochatUtil
								.wrapColor(
										MmochatConstant.bigmoneyNeedToChangSecondRoleType
												+ "元宝", Color.red) + "。";

				content += MmochatUtil.wrapColor("\n\n[仙魔介绍]", Color.green);
				content += "\n转生后会进入仙道或者魔道。仙道玩家进化的转生装备，"
						+ "只允许仙道玩家使用；魔道玩家进化的装备为魔道装备，也只有魔道玩家才能驾驭。";
				tlv.setContent(new Text(content));

				if (me.getSecond_role_type() != MmochatSecondRoleType.未转生) {
					tlv.setLeftName("转换");

					MmochatSecondRoleType newType;
					if (me.getSecond_role_type() == MmochatSecondRoleType.仙道) {
						newType = MmochatSecondRoleType.魔道;
					} else {
						newType = MmochatSecondRoleType.仙道;
					}
					CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
					msgbox
							.setContent(new Text(
									"您确定要放弃"
											+ me.getSecond_role_type()
													.toString()
											+ "，转为"
											+ MmochatUtil.wrapColor(newType
													.toString(), Color.red)
											+ "么?本次转换需要消耗"
											+ MmochatUtil
													.wrapColor(
															MmochatConstant.bigmoneyNeedToChangSecondRoleType
																	+ "元宝",
															Color.yellow) + "。"));
					msgbox.setLeftName("确定");
					msgbox.setRightName("取消");
					msgbox.addLeftTLV(new ClearDataTLV());
					msgbox.addLeftTLV(new SendDataTLV(MmochatConstant
							.getClientModuleId(),
							MmochatMain.getModuleInstID(),
							MmochatConstant.MSGCODE_MMOCHAT_C_9_30, (int) me
									.getRoleId()));
					tlv.addLeftTLV(msgbox);
				}
				return MmochatUtil.tlvResponse(req.getHallState(), tlv);
			}
			case 宠物转生: {
				if (me.getLife_turn() == 0) {
					return MmochatUtil.msgbox(req.getHallState(),
							"人物转生后才能对携带的宠物进行转生!您尚未转生。");
				}
				MmochatPet pet = me.getPkPet();
				if (pet == null) {
					return MmochatUtil.msgbox(req.getHallState(),
							"请将需要转生的宠生设置为"
									+ MmochatUtil.wrapColor("<参战>",
											Color.yellow) + "!");
				}
				CreateTlvWin tlv = new CreateTlvWin();
				tlv.setWinType(WinType.Text);
				tlv.setLeftName("转生");
				tlv.setRightName("返回");
				tlv.setTitle("宠物转生");
				tlv.setWinHeight(188);
				tlv.addRightTLV(new CloseWinTLV());
				boolean conditionIsOk = true;
				String content = MmochatUtil.wrapColor("请将需要转生的宠物设置为",
						Color.red)
						+ MmochatUtil.wrapColor("参战", Color.yellow);
				content += "\n当前参战宠物:" + pet.getPetTypeName();

				content += MmochatUtil.wrapColor("\n\n[转生条件]\n", Color.yellow);
				content += "1、等级要求达到" + MmochatConstant.maxLevel
						+ "级，并且经验达到129级升级经验。";
				if (pet.getLevel() == 129) {
					content += MmochatUtil.wrapColor("\n-等级达到要求", Color.green);
				} else {
					content += MmochatUtil.wrapColor("\n-等级未达到要求", Color.red);
					conditionIsOk = false;
				}

				if (pet.getExp() >= MmochatBattleService
						.getPetExpNeedToUplevel(pet.getLevel(), pet
								.getLife_turn())) {
					content += MmochatUtil.wrapColor("\n-经验达到要求", Color.green);
				} else {
					content += MmochatUtil.wrapColor("\n-经验未达到要求", Color.red);
					conditionIsOk = false;
				}

				content += "\n\n2、人物的转生次数要高于待转生的宠物。";
				if (me.getLife_turn() > pet.getLife_turn()) {
					content += MmochatUtil.wrapColor("\n-人物达到要求", Color.green);
				} else {
					content += MmochatUtil.wrapColor("\n-人物未达到要求", Color.red);
					conditionIsOk = false;
				}

				content += "\n\n3、野生宠物无法转生。";
				if (pet.getPetType() != MmochatPetType.野生) {
					content += MmochatUtil.wrapColor("\n-符合要求", Color.green);
				} else {
					content += MmochatUtil.wrapColor("\n-不符合要求", Color.red);
					conditionIsOk = false;
				}

				tlv.setContent(new Text(content));

				// 判断条件是否满足
				if (!conditionIsOk) {
					CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
					msgbox.setContent(new Text("您的参战宠物未达到转生条件!"));
					msgbox.setLeftName("确定");
					tlv.addLeftTLV(msgbox);
				} else {
					CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
					msgbox.setContent(new Text("您的参战宠物已经达到转生条件，您确定要进行第"
							+ (pet.getLife_turn() + 1) + "次宠物转生么?"));
					msgbox.setLeftName("确定");
					msgbox.setRightName("取消");
					msgbox.addLeftTLV(new ClearDataTLV());
					msgbox.addLeftTLV(new SendDataTLV(MmochatConstant
							.getClientModuleId(),
							MmochatMain.getModuleInstID(),
							MmochatConstant.MSGCODE_MMOCHAT_C_9_31, (int) me
									.getRoleId()));
					ShowWaitingMsgBoxTLV wait = new ShowWaitingMsgBoxTLV();
					wait.setShowCancel(false);
					msgbox.addLeftTLV(wait);
					tlv.addLeftTLV(msgbox);
				}

				return MmochatUtil.tlvResponse(req.getHallState(), tlv);
			}
			case 挑战周年纪念兽: {
				// 判断兽寿命
				MmochatTempNpc tmpNpc = (MmochatTempNpc) npc;
				if (tmpNpc.isTimeOut()) {
					tmpNpc.setState(MmochatNpcState.离开);
					npcs.remove(npc.getNpcId());
					MmochatMap curMap = MmochatMapService.maps.get(tmpNpc
							.getMapId());
					if (curMap != null) {
						curMap.delNpc(npc);
					}
					return MmochatUtil.msgbox(req.getHallState(),
							"纪念兽已经跑到其它地方了!");
				}

				// 判断队伍中是否有人已经有纪念兽蛋:包裹、仓库
				List<MmochatPlayer> members = new ArrayList<MmochatPlayer>();
				if (me.isInTeam()) {
					MmochatTeam team = MmochatTeamService.teams.get(me
							.getTeamId());
					if (team == null) {
						me.leaveTeam();
						members.add(me);
					} else {
						for (Integer roleId : team.getMemberId().values()) {
							MmochatPlayer member = MmochatMainService
									.getRoleFromBuffer(roleId);
							if (member != null) {
								members.add(member);
							}
						}
					}
				} else {
					members.add(me);
				}
				int teamNum = members.size();
				if (teamNum <= 0) {
					break;
				}
				int maxLevel = 0;
				for (MmochatPlayer player : members) {
					if (player == null) {
						continue;
					}
					if (player.getLevel() < 30) {
						return MmochatUtil.msgbox(req.getHallState(),
								MmochatUtil.wrapColor(player.getName(),
										Color.green)
										+ "的等级不足30级，无法参与此活动!");
					}
					maxLevel = Math.max(maxLevel, player.getTrueLevel());
					if (player.getPackageObjNum(MmochatPropType.一周年纪念蛋) > 0
							|| player.getStorageObjNum(MmochatPropType.一周年纪念蛋) > 0) {
						String myInfo = "您已经打到一个纪念蛋了，无法继续挑战。请先去"
								+ MmochatUtil.wrapColor("西郊", Color.yellow)
								+ "孵化!在西郊打怪有一定机率将"
								+ MmochatUtil.wrapColor("包裹中", Color.green)
								+ "的纪念蛋孵化出来!";
						if (me.getRoleId() == player.getRoleId()) {
							return MmochatUtil.msgbox(req.getHallState(),
									myInfo);
						} else {
							MmochatUtil.sendCommonMsgbox(player, myInfo);
							return MmochatUtil.msgbox(req.getHallState(),
									MmochatUtil.wrapColor(player.getName(),
											Color.green)
											+ "已经打到一个纪念蛋了，无法继续挑战，必需先进行孵化纪念蛋!");
						}
					}
				}

				// 开始战斗
				MmochatNpcBattle battle = new MmochatNpcBattle();
				int monsterNum = teamNum * 2;

				int equipLevel = 3;
				int expectTeamNum = 1;

				double bossPhysicalAttack = 0.25;
				double bossMagicAttack = 0.2;
				double bossPhysicalAttackPercent = 0.75;
				double bossMagicAttackPercent = 0.25;
				int bossSuperPhysicalAttack = 30;
				int bossSuperSpritAttack = 30;
				int bossMagicAttackNum = 2;

				double monsterPhysicalAttack = 0.25;
				double monsterMagicAttack = 0.2;
				double monsterPhysicalAttackPercent = 0.75;
				double monsterMagicAttackPercent = 0.25;
				int monsterSuperPhysicalAttack = 30;
				int monsterSuperSpritAttack = 30;

				MmochatMonsterFactory boss = new MmochatMonsterFactory();
				boss.setLevelType(MmochatBossLevelType.队伍最高等级);
				boss.setBmpType(MmochatRoleBmpType.龙宫);
				boss.setName("纪念兽");
				boss.setLevel(maxLevel);
				boss.setEquipLevel(equipLevel);
				boss.setTeamNum(expectTeamNum);
				boss.setKillRound(3);
				boss.setPhysical(bossPhysicalAttack);
				boss.setMagic(bossMagicAttack);
				boss.setSuperPhysicalAttack(bossSuperPhysicalAttack);
				boss.setSuperSpritAttack(bossSuperSpritAttack);
				boss.setBossMaxSkillTargetNum(bossMagicAttackNum);
				boss.setSpeedPointAddType(2);
				MmochatAttackModeOfNormal defaultAttackMode = new MmochatAttackModeOfNormal();
				defaultAttackMode
						.setPhysicalAttackOpportunity((int) (100 * bossPhysicalAttackPercent));
				defaultAttackMode
						.setMagicAttackOppotunity((int) (100 * bossMagicAttackPercent));
				defaultAttackMode
						.setLimitOppotunity((int) (100 * (1 - bossMagicAttackPercent - bossPhysicalAttackPercent)));
				boss.setAttackMode_normal(defaultAttackMode);
				boss.setDao((int) (2 * MmochatBattleService.getStandardDao(
						maxLevel, 0)));
				battle.setBoss(boss);

				List<MmochatMonsterFactory> monsters = new ArrayList<MmochatMonsterFactory>();
				for (int i = 0; i < monsterNum - 1; i++) {
					MmochatMonsterFactory monster = new MmochatMonsterFactory();
					monster.setLevelType(MmochatBossLevelType.队伍最高等级);
					monster.setBmpType(MmochatRoleBmpType.龙宫);
					monster.setName("纪念兽");
					monster.setLevel(maxLevel);
					monster.setEquipLevel(equipLevel);
					monster.setTeamNum(expectTeamNum);
					monster.setKillRound(3);
					monster.setPhysical(monsterPhysicalAttack);
					monster.setMagic(monsterMagicAttack);
					monster.setSuperPhysicalAttack(monsterSuperPhysicalAttack);
					monster.setSuperSpritAttack(monsterSuperSpritAttack);
					monster.setBossMaxSkillTargetNum(2);
					monster.setSpeedPointAddType(2);
					MmochatAttackModeOfNormal attackMode = new MmochatAttackModeOfNormal();
					attackMode
							.setPhysicalAttackOpportunity((int) (100 * monsterPhysicalAttackPercent));
					attackMode
							.setMagicAttackOppotunity((int) (100 * monsterMagicAttackPercent));
					attackMode.setLimitOppotunity(0);
					monster.setAttackMode_normal(attackMode);
					// 道行在1~2倍之间
					monster.setDao((int) (2 * MmochatBattleService
							.getStandardDao(maxLevel, 0)));
					monsters.add(monster);
				}
				battle.setSmallBoss(monsters);

				MmochatTask task = new MmochatTask();
				task.setTaskType(MmochatTaskType.挑战纪念兽);
				task.setFinish_need_battles(battle);
				MmochatBattleService.enterNpcPk(me.getMapId(), (byte) me
						.getLine(), members, me.getRoleId(), task, req
						.getNpcId());
				break;

			}
			case 驱赶年兽: {
				// 判断年兽寿命
				MmochatTempNpc tmpNpc = (MmochatTempNpc) npc;
				if (tmpNpc.isTimeOut()) {
					tmpNpc.setState(MmochatNpcState.离开);
					npcs.remove(npc.getNpcId());
					MmochatMap curMap = MmochatMapService.maps.get(tmpNpc
							.getMapId());
					if (curMap != null) {
						curMap.delNpc(npc);
					}
					return MmochatUtil.msgbox(req.getHallState(),
							"年兽已经跑到其它地方了!");
				}

				// 判断队伍中是否有人已经有年兽蛋:包裹、仓库
				List<MmochatPlayer> members = new ArrayList<MmochatPlayer>();
				if (me.isInTeam()) {
					MmochatTeam team = MmochatTeamService.teams.get(me
							.getTeamId());
					if (team == null) {
						me.leaveTeam();
						members.add(me);
					} else {
						for (Integer roleId : team.getMemberId().values()) {
							MmochatPlayer member = MmochatMainService
									.getRoleFromBuffer(roleId);
							if (member != null) {
								members.add(member);
							}
						}
					}
				} else {
					members.add(me);
				}
				int teamNum = members.size();
				if (teamNum <= 0) {
					break;
				}
				int maxLevel = 0;
				for (MmochatPlayer player : members) {
					if (player == null) {
						continue;
					}
					if (player.getLevel() < 30) {
						return MmochatUtil.msgbox(req.getHallState(),
								MmochatUtil.wrapColor(player.getName(),
										Color.green)
										+ "的等级不足30级，无法参与此活动!");
					}
					maxLevel = Math.max(maxLevel, player.getTrueLevel());
					if (player.getPackageObjNum(MmochatPropType.年兽蛋) > 0
							|| player.getStorageObjNum(MmochatPropType.年兽蛋) > 0) {
						String myInfo = "您已经打到一个年兽蛋了，无法继续驱赶年兽。请先去"
								+ MmochatUtil.wrapColor("西郊", Color.yellow)
								+ "孵化!在西郊打怪有一定机率将"
								+ MmochatUtil.wrapColor("包裹中", Color.green)
								+ "的年兽蛋孵化出来!";
						if (me.getRoleId() == player.getRoleId()) {
							return MmochatUtil.msgbox(req.getHallState(),
									myInfo);
						} else {
							MmochatUtil.sendCommonMsgbox(player, myInfo);
							return MmochatUtil
									.msgbox(req.getHallState(), MmochatUtil
											.wrapColor(player.getName(),
													Color.green)
											+ "已经打到一个年兽蛋了，无法继续驱赶年兽，必需先进行孵化年兽蛋!");
						}
					}
				}

				// 开始战斗
				MmochatNpcBattle battle = new MmochatNpcBattle();
				int monsterNum = teamNum * 2;

				int equipLevel = 3;
				int expectTeamNum = 1;

				double bossPhysicalAttack = 0.25;
				double bossMagicAttack = 0.2;
				double bossPhysicalAttackPercent = 0.75;
				double bossMagicAttackPercent = 0.25;
				int bossSuperPhysicalAttack = 30;
				int bossSuperSpritAttack = 30;
				int bossMagicAttackNum = 2;

				double monsterPhysicalAttack = 0.25;
				double monsterMagicAttack = 0.2;
				double monsterPhysicalAttackPercent = 0.75;
				double monsterMagicAttackPercent = 0.25;
				int monsterSuperPhysicalAttack = 30;
				int monsterSuperSpritAttack = 30;

				MmochatMonsterFactory boss = new MmochatMonsterFactory();
				boss.setLevelType(MmochatBossLevelType.队伍最高等级);
				boss.setBmpType(MmochatRoleBmpType.怪物);
				boss.setName("年兽");
				boss.setLevel(maxLevel);
				boss.setEquipLevel(equipLevel);
				boss.setTeamNum(expectTeamNum);
				boss.setKillRound(3);
				boss.setPhysical(bossPhysicalAttack);
				boss.setMagic(bossMagicAttack);
				boss.setSuperPhysicalAttack(bossSuperPhysicalAttack);
				boss.setSuperSpritAttack(bossSuperSpritAttack);
				boss.setBossMaxSkillTargetNum(bossMagicAttackNum);
				boss.setSpeedPointAddType(2);
				MmochatAttackModeOfNormal defaultAttackMode = new MmochatAttackModeOfNormal();
				defaultAttackMode
						.setPhysicalAttackOpportunity((int) (100 * bossPhysicalAttackPercent));
				defaultAttackMode
						.setMagicAttackOppotunity((int) (100 * bossMagicAttackPercent));
				defaultAttackMode
						.setLimitOppotunity((int) (100 * (1 - bossMagicAttackPercent - bossPhysicalAttackPercent)));
				boss.setAttackMode_normal(defaultAttackMode);
				boss.setDao((int) (2 * MmochatBattleService.getStandardDao(
						maxLevel, 0)));
				battle.setBoss(boss);

				List<MmochatMonsterFactory> monsters = new ArrayList<MmochatMonsterFactory>();
				for (int i = 0; i < monsterNum - 1; i++) {
					MmochatMonsterFactory monster = new MmochatMonsterFactory();
					monster.setLevelType(MmochatBossLevelType.队伍最高等级);
					monster.setBmpType(MmochatRoleBmpType.怪物);
					monster.setName("年兽");
					monster.setLevel(maxLevel);
					monster.setEquipLevel(equipLevel);
					monster.setTeamNum(expectTeamNum);
					monster.setKillRound(3);
					monster.setPhysical(monsterPhysicalAttack);
					monster.setMagic(monsterMagicAttack);
					monster.setSuperPhysicalAttack(monsterSuperPhysicalAttack);
					monster.setSuperSpritAttack(monsterSuperSpritAttack);
					monster.setBossMaxSkillTargetNum(2);
					monster.setSpeedPointAddType(2);
					MmochatAttackModeOfNormal attackMode = new MmochatAttackModeOfNormal();
					attackMode
							.setPhysicalAttackOpportunity((int) (100 * monsterPhysicalAttackPercent));
					attackMode
							.setMagicAttackOppotunity((int) (100 * monsterMagicAttackPercent));
					attackMode.setLimitOppotunity(0);
					monster.setAttackMode_normal(attackMode);
					// 道行在1~2倍之间
					monster.setDao((int) (2 * MmochatBattleService
							.getStandardDao(maxLevel, 0)));
					monsters.add(monster);
				}
				battle.setSmallBoss(monsters);

				MmochatTask task = new MmochatTask();
				task.setTaskType(MmochatTaskType.驱赶年兽);
				task.setFinish_need_battles(battle);
				MmochatBattleService.enterNpcPk(me.getMapId(), (byte) me
						.getLine(), members, me.getRoleId(), task, req
						.getNpcId());
				break;
			}
			case 退回原服务器: {
				// 停止战斗
				if (me.isInBattle()) {
					MmochatBattle battle = MmochatBattleService.battles.get(me
							.getBattleId());
					if (battle != null) {
						battle.closeBattle();
					}
				}
				// 积分清0
				me.setCommonActivityScore(0);
				// 离队
				if (me.isInTeam()) {
					MmochatTeam team = MmochatTeamService.teams.get(me
							.getTeamId());
					team.leaveTeam(me.getRoleId());
				}

				// 返回原服务器
				MmochatBackToOldServer pack = new MmochatBackToOldServer(me
						.getRegServerInstId());
				pack.setRoleId(me.getRoleId());
				MmochatUtil.sendMultiServerPack(pack);
				// 从本跨服服务器中清除
				MmochatMainService.leaveGame(me, false);
				break;
			}
			case 威望兑换: {

				CreateTlvWin tlv = new CreateTlvWin();
				tlv.setWinType(WinType.List);
				tlv.setLeftName("查看");
				tlv.setRightName("返回");
				tlv.setTitle("威望兑换");
				tlv.setWinHeight(188);
				tlv.addRightTLV(new CloseWinTLV());

				tlv.addItemEvent("查看我的威望", new ClearDataTLV(), new AddDataTLV(
						(int) 1));
				tlv.addItemEvent("兑换经验", new ClearDataTLV(), new AddDataTLV(
						(int) 2));
				tlv.addItemEvent("兑换道行", new ClearDataTLV(), new AddDataTLV(
						(int) 3));
				tlv.addItemEvent("威望抽奖", new ClearDataTLV(), new AddDataTLV(
						(int) 8));
				tlv.addItemEvent("兑换金钱袋", new ClearDataTLV(), new AddDataTLV(
						(int) 4));
				tlv.addItemEvent("兑换神兽", new ClearDataTLV(), new AddDataTLV(
						(int) 5));
				tlv.addItemEvent("兑换8级浮云", new ClearDataTLV(), new AddDataTLV(
						(int) 6));
				tlv.addItemEvent("威望竞猜", new ClearDataTLV(), new AddDataTLV(
						(int) 7));

				tlv.addLeftTLV(new SendDataTLV(MmochatConstant
						.getClientModuleId(), MmochatMain.getModuleInstID(),
						MmochatConstant.MSGCODE_MMOCHAT_C_9_34, (int) me
								.getRoleId()));
				tlv.addLeftTLV(new ShowWaitingMsgBoxTLV());

				return MmochatUtil.tlvResponse(req.getHallState(), tlv);
			}
			case 跨服试道说明: {
				CreateTlvWin tlv = new CreateTlvWin();
				tlv.setWinType(WinType.Text);
				tlv.setRightName("返回");
				tlv.setTitle("跨服试道说明");
				tlv.setWinHeight(188);
				tlv.addRightTLV(new CloseWinTLV());
				String content = "";
				content += MmochatUtil.wrapColor("[比赛时间]\n", Color.yellow);
				content += "每周四，报名时间:19:30-20:00，比赛时间:20:00-22:00\n\n";
				content += MmochatUtil.wrapColor("[报名流程]\n", Color.yellow);
				content += "在<武道会传送人>处申请参加跨服武道，申请成功后，退出本服，由<跨服专区>进入比赛场地!\n\n";
				content += MmochatUtil.wrapColor("[入场条件]\n", Color.yellow);
				content += "具有<试道王者>称谓，或者身上具有<武神光环>效果的玩家，才有资格入场。"
						+ "如果在比赛中掉线，可在10分钟内直接重登<跨服专区>重返战场。\n\n";
				content += MmochatUtil.wrapColor("[比赛规则]\n", Color.yellow);
				content += "30级开始，每10级为一个等级段进行比赛。每个玩家初始体力为"
						+ MmochatMultiServerWuDaoPkGame.initScore
						+ "点，体力为0时淘汰。如果战斗时间为N分钟，则8点-9点期间，"
						+ "战斗失败扣除(N+15)点体力，战斗胜利扣除(N-10)点体力；"
						+ "9点-10点期间，战斗失败扣除(2倍N+30)点体力，战斗胜利"
						+ "扣除(1.5倍N-10)点体力。战斗回合超限则双方都按失败扣除体力。"
						+ "同区服玩家间不会进行比赛，不同区服玩家间无法组队。\n\n";
				content += MmochatUtil.wrapColor("[胜出规则]\n", Color.yellow);
				content += "当场内只剩3个区服时，这3个区服晋级前三强，并获得前三强奖励；"
						+ "当场内只剩2个区服时，这2个区服晋级前二强，并获得前二强奖励；"
						+ "当场内只剩1个区服时，这个区服获得冠军，并获得冠军奖励。\n\n";
				content += MmochatUtil.wrapColor("[比赛奖励]\n", Color.yellow);
				content += "比赛过程中，每次战斗胜利将获得"
						+ MmochatConstant.honorAwardForMultiWuDaoWinPerPk
						+ "点威望奖励，战斗失败将获得"
						+ MmochatConstant.honorAwardForMultiWuDaoLosePerPk
						+ "点威望奖励。\n" + "最终胜出的第一名区服玩家获得5000点威望、6天的<跨服王者>称号；"
						+ "第二名区服玩家获得3000点威望、6天的<跨服高手>称号；"
						+ "第三名区服玩家获得2000点威望、6天的<跨服新贵>称号；威望可以在本人这里兑换各种奖励。";
				tlv.setContent(new Text(content));

				return MmochatUtil.tlvResponse(req.getHallState(), tlv);
			}
			case 创建钱庄密码: {
				if (me.getStore_pwd_state() != MmochatStorePwdState.未设置钱庄密码) {
					return MmochatUtil.msgbox(req.getHallState(), "您已经有钱庄密码了!");
				}

				CreateEditBoxTLV edit = new CreateEditBoxTLV();
				edit
						.setTitle("请输入您要创建的钱庄密码，6到18个字!设置后请牢记，"
								+ "如果忘记密码，您可以清除钱庄密码，清除密码需要"
								+ (MmochatConstant.releaseStorePwdInterval / MmochatConstant.MS_PER_DAY)
								+ "天时间!");
				edit.setLeftName("创建");
				edit.setRightName("取消");
				edit.setContentLenMax(18);
				edit.setBoxType(CreateEditBoxTLV.TYPE_MSGBOX);
				edit.setInputType(CreateEditBoxTLV.INPUT_ANY << 4);
				edit.addLeftTLV(new ClearDataTLV());
				edit.addLeftTLV(new AddDataTLV((int) me.getRoleId()));
				edit.addLeftTLV(new AddEditBoxTLV());
				edit.addLeftTLV(new SendDataTLV(MmochatConstant
						.getClientModuleId(), MmochatMain.getModuleInstID(),
						MmochatConstant.MSGCODE_MMOCHAT_C_9_44, null));
				ShowWaitingMsgBoxTLV wait = new ShowWaitingMsgBoxTLV();
				wait.setShowCancel(false);
				edit.addLeftTLV(wait);

				return MmochatUtil.tlvResponse(req.getHallState(), edit);
			}
			case 修改钱庄密码: {
				if (me.getStore_pwd_state() == MmochatStorePwdState.未设置钱庄密码) {
					return MmochatUtil.msgbox(req.getHallState(),
							"您还没有钱庄密码，请先创建钱庄密码!");
				}
				CreateEditBoxTLV edit = new CreateEditBoxTLV();
				edit.setTitle("请输入当前钱庄密码!");
				edit.setLeftName("确定");
				edit.setRightName("取消");
				edit.setContentLenMax(18);
				edit.setBoxType(CreateEditBoxTLV.TYPE_MSGBOX);
				edit.setInputType(CreateEditBoxTLV.INPUT_ANY << 4);
				edit.addLeftTLV(new ClearDataTLV());
				edit.addLeftTLV(new AddDataTLV((int) me.getRoleId()));
				edit.addLeftTLV(new AddEditBoxTLV());
				edit.addLeftTLV(new SendDataTLV(MmochatConstant
						.getClientModuleId(), MmochatMain.getModuleInstID(),
						MmochatConstant.MSGCODE_MMOCHAT_C_9_45, null));
				ShowWaitingMsgBoxTLV wait = new ShowWaitingMsgBoxTLV();
				edit.addLeftTLV(wait);

				return MmochatUtil.tlvResponse(req.getHallState(), edit);
			}
			case 清除钱庄密码: {
				CreateTlvWin tlv = getClearStorePwdTlv(me);
				return MmochatUtil.tlvResponse(req.getHallState(), tlv);
			}
			case 领取补偿: {
				if (me.getExtra() == 0) {
					return MmochatUtil.msgbox(req.getHallState(), "您没有未领取的补偿!");
				}
				if (me.getExtra() == 1) {
					if (!me.hasEnoughPackageSpace(1)) {
						return MmochatUtil.msgbox(req.getHallState(),
								"请先保留1个包裹空位!");
					}
					MmochatProp p = new MmochatProp(MmochatPropType.江湖名号);
					p.setCanDeal(false);
					me.addObjectToPackage(p);
					long oldExtra = me.getExtra();
					me.setExtra(0);
					try {
						MmochatDao.updateExtraAndPackage(me);
					} catch (Exception e) {
						e.printStackTrace();
						me.setExtra(oldExtra);
						me.delPackageObj(MmochatPropType.江湖名号, 1);
					}
					return MmochatUtil.msgbox(req.getHallState(), "您获得了一个"
							+ MmochatUtil.wrapColor("江湖名号", Color.yellow) + "!"
							+ "补偿说明：由于合服时，您的角色名与另一区玩家重名，"
							+ "您的角色名被系统修改，因为补偿您一个江湖名号。");
				}
				break;
			}
			case 开启血魔副本: {
				if (!MmochatConstant.isCreateFuBenAllowed) {
					return MmochatUtil.msgbox(req.getHallState(),
							"服务器将在1小时内维护，暂时不能创建副本，以免造成损失!");
				}
				if (!me.hasGang()) {
					return MmochatUtil.msgbox(req.getHallState(), "您还没有帮派!");
				}
				MmochatGang myGang = MmochatGangService.getGangById(me
						.getGangId());
				if (myGang == null) {
					return MmochatUtil.msgbox(req.getHallState(), "您还没有帮派!");
				}
				MmochatGangMember myInfo = myGang.getMembers().get(
						me.getRoleId());
				if (myInfo == null) {
					return MmochatUtil.msgbox(req.getHallState(), "您不在此帮派!");
				}
				if (myInfo.getType() != MmochatGangMemberType.帮主
						&& myInfo.getType() != MmochatGangMemberType.副帮) {
					return MmochatUtil.msgbox(req.getHallState(),
							"只有帮主、副帮主才能开启血魔副本!");
				}
				cleanTimeOutGangFuBen(myGang);
				if (myGang.isInFuBenActivity()) {
					return MmochatUtil.msgbox(req.getHallState(),
							"本帮当前已经开启血魔副本，无须再开!");
				}

				// 50,100,200,300
				int onlineNeed = 0;
				switch (myGang.getLevel()) {
				case 初级:
					onlineNeed = 10;
					break;
				case 中级:
					onlineNeed = 20;
					break;
				case 高级:
					onlineNeed = 30;
					break;
				case 顶级:
					onlineNeed = 40;
					break;
				default:
					break;
				}
				int curOnlineNum = 0;
				for (MmochatGangMember member : myGang.getMembers().values()) {
					if (MmochatMainService.isPlayerOnline(member.getRoleId())) {
						curOnlineNum++;
					}
				}
				if (curOnlineNum < onlineNeed) {
					return MmochatUtil.msgbox(req.getHallState(), myGang
							.getLevel().toString()
							+ "帮派开启副本需要至少"
							+ onlineNeed
							+ "人在线，当前本帮在线"
							+ curOnlineNum + "人!");
				}

				// 开启副本，并增加次数
				synchronized (myGang) {
					MmochatDailyActivity activity = myGang.getDailyActivities()
							.get(MmochatDailyActivityType.血魔副本);
					if (activity == null) {
						// 第一次参加此活动
						activity = new MmochatDailyActivity();
						activity.setType(MmochatDailyActivityType.血魔副本);
						myGang.addDailyActivity(activity);
					}
					if (activity != null) {
						Date now = new Date();
						Date lastDate = new Date(activity.getLastTime());
						if (now.getDate() == lastDate.getDate()
								&& now.getMonth() == lastDate.getMonth()
								&& now.getYear() == lastDate.getYear()) {
							// 今天参加过
							if (activity.getDailyTimes() >= activity.getType()
									.getMaxDailyTimes()) {
								return MmochatUtil.msgbox(req.getHallState(),
										"血魔副本每天只能开启"
												+ activity.getType()
														.getMaxDailyTimes()
												+ "次，请明天再来!");
							} else {
								activity.addDailyTimes(1);
							}
						} else {
							// 今天没有参加过此活动
							activity.setLastTime(now.getTime());
							activity.setDailyTimes(1);
						}
					}
				}

				int hardParam = 1; // 难度系数
				long fuBenTime = MmochatConstant.MS_PER_HOUR * 3;
				MmochatGangFuBen fuBen = new MmochatGangFuBen();
				MmochatFuBenType fuBenType = MmochatFuBenType.初级血魔副本;
				switch (myGang.getLevel()) {
				case 初级:
					fuBenType = MmochatFuBenType.初级血魔副本;
					hardParam = 1;
					break;
				case 中级:
					fuBenType = MmochatFuBenType.中级血魔副本;
					hardParam = 2;
					break;
				case 高级:
					fuBenType = MmochatFuBenType.高级血魔副本;
					hardParam = 4;
					break;
				case 顶级:
					fuBenType = MmochatFuBenType.顶级血魔副本;
					hardParam = 6;
					break;
				default:
					break;
				}
				fuBen.setType(fuBenType);
				fuBen.setLifeTime(fuBenTime);
				fuBen.setGangId(myGang.getId());
				fuBen.setHardParam(hardParam);
				fuBen.setLine(me.getLine());
				gangFuBens.put(fuBen.getId(), fuBen);
				myGang.setFuBenId(fuBen.getId());

				// TODO:放怪
				// 50,100,200,300
				// 初级：第一拨放8个小怪
				int minX = 48, maxX = 382;
				int minY = 168, maxY = 444;
				int monsterNum = hardParam
						* MmochatConstant.monsterNumOfGangFuBen1Step1;
				MmochatMap mainMap = MmochatMapService.getMapByMapId(myGang
						.getMapId());
				for (int i = 0; i < monsterNum; i++) {
					MmochatTempNpc monster = new MmochatTempNpc(true);
					monster.setLifeTime(fuBenTime);
					monster.setLine(fuBen.getLine());
					monster.setMapId(myGang.getMapId());
					monster
							.setX((short) MmochatUtil
									.getRandomValue(minX, maxX));
					monster
							.setY((short) MmochatUtil
									.getRandomValue(minY, maxY));
					monster.setName("树怪");
					monster.setBmpType(MmochatRoleBmpType.树);
					monster.getFunctionItems().add(MmochatNpcItemType.击杀树怪);
					npcs.put(monster.getNpcId(), monster);
					mainMap.addNpc(fuBen.getLine(), monster);
				}

				// 通知帮派成员
				String msg = "本帮已开启"
						+ MmochatUtil.wrapColor(fuBenType.toString(),
								Color.magenta)
						+ ","
						+ "请大家通过帮派使者回到帮派地图"
						+ MmochatUtil.wrapColor((fuBen.getLine() + 1) + "线",
								Color.green) + "前去击杀树怪!";
				msg = MmochatUtil.wrapColor(msg, Color.yellow);
				MmochatGangService.sendMsgToAllGangMembersByFriendMsg(myGang,
						msg);
				MmochatGangService.sendGangSystemMsg(myGang, msg);

				// 保存fubenId,activity
				try {
					MmochatDao.updateGangFuBenInfo(myGang);
				} catch (Exception e) {
					e.printStackTrace();
				}
				return MmochatUtil.msgbox(req.getHallState(), "开启成功!");
			}
			case 血魔副本介绍: {
				CreateTlvWin tlv = new CreateTlvWin();
				tlv.setWinType(WinType.Text);
				tlv.setRightName("返回");
				tlv.setTitle("血魔副本介绍");
				tlv.setWinHeight(188);
				tlv.addRightTLV(new CloseWinTLV());

				String content = "";
				content += MmochatUtil.wrapColor("[副本流程]", Color.yellow) + "\n";
				content += "此副本由帮主或副帮主开启，每天可以创建"
						+ MmochatDailyActivityType.血魔副本.getMaxDailyTimes()
						+ "次，开启后即计为1次，帮派贡献度达到500的成员都可以参加。需要在3小时内完成副本，"
						+ "超时则本次副本失败。副本开启后，在帮派地图中会出现若干个树妖，击杀到一定数量后，"
						+ "出现大力虎、白发魔女，大力虎抗物理50%，白发魔女抗法术50%。"
						+ "大力虎和白发魔女被击杀到一定数量后，血魔出现。击杀完所有怪物副本完成。"
						+ "所有怪物战斗难度取决于队伍最高等级。\n\n";
				content += MmochatUtil.wrapColor("[副本奖励]", Color.yellow) + "\n";
				content += "杀完每个怪物时，都会获得帮贡和建设度奖励，并有一定机率获得各类技能秘籍、秘籍时间书。\n\n";
				content += MmochatUtil.wrapColor("[血魔特点]", Color.yellow) + "\n";
				content += "血魔为7倍标准道行，不会障碍技能。拥有2个特殊技能：秒10绝技、嗜血绝技。\n\n";
				content += MmochatUtil.wrapColor("[秒10绝技]", Color.yellow)
						+ "\n";
				content += "此技能在施放前一回合，系统会通过战斗聊天进行通知。"
						+ "此技能目标数10个，击中即死，但在施放那一回合(所有人操作完毕之前)，"
						+ "发布聊天指令<隐身>可进行闪避。\n\n";
				content += MmochatUtil.wrapColor("[嗜血绝技]", Color.yellow) + "\n";
				content += "此技能在施放前一回合，系统会通过战斗聊天进行通知。"
						+ "此技能对血魔自己使用，使用后提升伤害400%，持续3个回合。"
						+ "在此技能施放的那一回合(所有人操作完毕之前)，如果有人发布聊天指令<引怪>，"
						+ "则血魔将放弃嗜血，改为物攻此玩家。\n\n";
				content += MmochatUtil.wrapColor("[聊天指令]", Color.yellow) + "\n";
				content += "聊天指令是在特定副本中使用的。只要在副本战斗中，发布战斗聊天消息，消息内容为指定的"
						+ "指令语，就可能实现一定的效果。如在血魔副本，可以使用：隐身、引怪。聊天指令效果只有一回合，"
						+ "下一回合效果自动消失。";

				tlv.setContent(new Text(content));
				return MmochatUtil.tlvResponse(req.getHallState(), tlv);

			}
			case 击杀树怪: {
				String msg = MmochatBattleService.enterGangModelBattle(me, npc,
						MmochatBattleModelType.血魔副本之树妖,
						MmochatTaskType.击杀血魔副本之树妖);
				if (msg != null) {
					return MmochatUtil.msgbox(req.getHallState(), msg);
				}
				break;
			}
			case 击杀大力虎: {
				String msg = MmochatBattleService.enterGangModelBattle(me, npc,
						MmochatBattleModelType.血魔副本之大力虎,
						MmochatTaskType.击杀血魔副本之大力虎);
				if (msg != null) {
					return MmochatUtil.msgbox(req.getHallState(), msg);
				}
				break;
			}
			case 击杀白发魔女: {
				String msg = MmochatBattleService.enterGangModelBattle(me, npc,
						MmochatBattleModelType.血魔副本之白发魔女,
						MmochatTaskType.击杀血魔副本之白发魔女);
				if (msg != null) {
					return MmochatUtil.msgbox(req.getHallState(), msg);
				}
				break;
			}
			case 击杀血魔: {
				String msg = MmochatBattleService.enterGangModelBattle(me, npc,
						MmochatBattleModelType.血魔副本之终级BOSS,
						MmochatTaskType.击杀血魔副本之终极BOSS);
				if (msg != null) {
					return MmochatUtil.msgbox(req.getHallState(), msg);
				}
				break;
			}
			case 创建普通三仙岛副本:
			case 创建高级三仙岛副本: {
				if (!MmochatConstant.isCreateFuBenAllowed) {
					return MmochatUtil.msgbox(req.getHallState(),
							"服务器将在1小时内维护，暂时不能创建副本，以免造成损失!");
				}
				List<MmochatPlayer> members = new ArrayList<MmochatPlayer>();
				if (me.isInTeam()) {
					MmochatTeam team = MmochatTeamService.teams.get(me
							.getTeamId());
					if (team == null) {
						me.leaveTeam();
						members.add(me);
					} else {
						for (Integer roleId : team.getMemberId().values()) {
							MmochatPlayer member = MmochatMainService.players
									.get(roleId);
							if (member != null) {
								members.add(member);
							}
						}
					}
				} else {
					members.add(me);
				}
				// int teamNum = members.size();
				// if (teamNum < 5) {
				// return MmochatUtil.msgbox(req.getHallState(), "请组满5人再创建副本!");
				// }
				// 等级判定、副本次数判定、当前是否已经有副本任务、金钱判定
				Date now = new Date();
				int maxLevel = 0;
				for (MmochatPlayer member : members) {
					maxLevel = Math.max(maxLevel, member.getTrueLevel());
					// 等级
					if (member.getLevel() < 30) {
						return MmochatUtil.msgbox(req.getHallState(),
								MmochatUtil.wrapColor(member.getName(),
										Color.green)
										+ "等级未满30级，不能参加副本!");
					}

					// 是否已经在副本中了
					cleanTimeOutFuBenForRole(member);
					if (member.isInFuBenActivity()) {
						if (member.getRoleId() != me.getRoleId()) {
							MmochatUtil.sendCommonMsgbox(member,
									"您当前已经有一个未完成的副本，请先完成后再参加新的副本!");
							return MmochatUtil.msgbox(req.getHallState(),
									MmochatUtil.wrapColor(member.getName(),
											Color.green)
											+ "当前已经有一个未完成的副本，无法参加新的副本!");
						} else {
							return MmochatUtil.msgbox(req.getHallState(),
									"您当前已经有一个未完成的副本，请先完成后再参加新的副本!");
						}
					}

					// 参加次数
					MmochatDailyActivity activity = member.getDailyActivities()
							.get(MmochatDailyActivityType.三仙岛);
					if (activity != null) {
						Date lastDate = new Date(activity.getLastTime());
						if (now.getDate() == lastDate.getDate()
								&& now.getMonth() == lastDate.getMonth()
								&& now.getYear() == lastDate.getYear()) {
							// 今天参加过
							if (activity.getDailyTimes() >= activity.getType()
									.getMaxDailyTimes()) {
								if (member.getRoleId() != me.getRoleId()) {
									MmochatUtil.sendCommonMsgbox(member,
											"您今天已经参加过"
													+ activity.getType()
															.getMaxDailyTimes()
													+ "次三仙岛副本了，请明天再来!");
									return MmochatUtil.msgbox(req
											.getHallState(), MmochatUtil
											.wrapColor(member.getName(),
													Color.green)
											+ "今天已经参加过"
											+ activity.getType()
													.getMaxDailyTimes()
											+ "次三仙岛副本了，今天不能再参加了!");
								} else {
									return MmochatUtil.msgbox(req
											.getHallState(), "您今天已经参加过"
											+ activity.getType()
													.getMaxDailyTimes()
											+ "次三仙岛副本了，请明天再来!");
								}
							}
						}
					}

					// 金钱判定
					if (member.getSmall_money() < MmochatConstant.moneyNeedForSanXianDaoFuBen) {
						if (member.getRoleId() != me.getRoleId()) {
							MmochatUtil
									.sendCommonMsgbox(
											member,
											"进入三仙岛副本需要花费"
													+ MmochatUtil
															.getColorMoney(MmochatConstant.moneyNeedForSanXianDaoFuBen)
													+ "文钱，您的金钱不足!");
							return MmochatUtil
									.msgbox(
											req.getHallState(),
											"进入三仙岛副本需要花费"
													+ MmochatUtil
															.getColorMoney(MmochatConstant.moneyNeedForSanXianDaoFuBen)
													+ "文钱，"
													+ MmochatUtil.wrapColor(
															member.getName(),
															Color.green)
													+ "的金钱不足!");
						} else {
							return MmochatUtil
									.msgbox(
											req.getHallState(),
											"进入三仙岛副本需要花费"
													+ MmochatUtil
															.getColorMoney(MmochatConstant.moneyNeedForSanXianDaoFuBen)
													+ "文钱，您的金钱不足!");
						}
					}
				}
				// 扣除金钱、创建副本地图
				long fuBenTime = MmochatConstant.MS_PER_HOUR * 2;
				MmochatFuBen fuBen = new MmochatFuBen();
				if (type == MmochatNpcItemType.创建高级三仙岛副本) {
					fuBen.setType(MmochatFuBenType.高级三仙岛);
				} else {
					fuBen.setType(MmochatFuBenType.普通三仙岛);
				}
				fuBen.setLifeTime(fuBenTime);// 副本时间2小时
				fuBen.setLine(me.getLine());
				int gangId = me.getGangId();
				boolean isSameGang = true;
				for (MmochatPlayer member : members) {
					if (member.getGangId() != gangId) {
						isSameGang = false;
					}
					member.addAndUpdateSmall_money(-1
							* MmochatConstant.moneyNeedForSanXianDaoFuBen);
					member.setFuBenId(fuBen.getId());
					fuBen.addOwner(member.getRoleId());
					MmochatStatisticsService.addSmallMoneyCost(
							MmochatSmallMoneyCostType.三仙岛副本,
							-1 * MmochatConstant.moneyNeedForSanXianDaoFuBen);
				}
				if (members.size() >= 3 && isSameGang && gangId >= 0) {
					// 3人以上，且都是同一个帮
					fuBen.setGangFuBen(true);
				}
				fuBen.setFuBenLevel(maxLevel);// 队伍最高等级为副本等级
				fuBen.setEntryX(381);
				fuBen.setEntryY(251);
				fuBens.put(fuBen.getId(), fuBen);

				// 副本地图
				MmochatMap mainMap = new MmochatMap();
				mainMap.setMapId(MmochatMap.createTempMapId());
				MmochatMap subMap1 = new MmochatMap();
				subMap1.setMapId(MmochatMap.createTempMapId());
				MmochatMap subMap2 = new MmochatMap();
				subMap2.setMapId(MmochatMap.createTempMapId());
				MmochatMap subMap3 = new MmochatMap();
				subMap3.setMapId(MmochatMap.createTempMapId());

				MmochatMapService.maps.put(mainMap.getMapId(), mainMap);
				fuBen.addMap(mainMap);
				MmochatMapService.maps.put(subMap1.getMapId(), subMap1);
				fuBen.addMap(subMap1);
				MmochatMapService.maps.put(subMap2.getMapId(), subMap2);
				fuBen.addMap(subMap2);
				MmochatMapService.maps.put(subMap3.getMapId(), subMap3);
				fuBen.addMap(subMap3);

				/******* 三仙岛 *******/
				mainMap.setMapDataId(43);
				mainMap.setCanChangeLine(false);
				mainMap.setWalkToBattle(false);
				mainMap.setCanTransToFriend(false);
				mainMap.setMapName("三仙岛");
				mainMap.getBattleOrders().add(MmochatBattleOrderType.隐身);

				// 传送点
				MmochatMapTransPoint trans = new MmochatMapTransPoint();
				trans.setX(373);
				trans.setY(131);
				trans.setTransToMapId(subMap2.getMapId());
				trans.setNewMapX(193);
				trans.setNewMapY(193);
				mainMap.getTransPoints().add(trans);

				trans = new MmochatMapTransPoint();
				trans.setX(466);
				trans.setY(179);
				trans.setTransToMapId(subMap1.getMapId());
				trans.setNewMapX(193);
				trans.setNewMapY(193);
				mainMap.getTransPoints().add(trans);

				trans = new MmochatMapTransPoint();
				trans.setX(533);
				trans.setY(290);
				trans.setTransToMapId(subMap3.getMapId());
				trans.setNewMapX(193);
				trans.setNewMapY(193);
				mainMap.getTransPoints().add(trans);

				// hints
				MmochatMapHint hint = new MmochatMapHint();
				hint.setX(512);
				hint.setY(152);
				hint.setType(MmochatMapHintType.传送口);
				hint.setHint("天绝");
				mainMap.getHints().add(hint);

				hint = new MmochatMapHint();
				hint.setX(404);
				hint.setY(88);
				hint.setType(MmochatMapHintType.传送口);
				hint.setHint("地灭");
				mainMap.getHints().add(hint);

				hint = new MmochatMapHint();
				hint.setX(581);
				hint.setY(252);
				hint.setType(MmochatMapHintType.传送口);
				hint.setHint("风生");
				mainMap.getHints().add(hint);
				// npc
				MmochatTempNpc boss = new MmochatTempNpc(true);
				boss.setLifeTime(fuBenTime);
				boss.setLine(me.getLine());
				boss.setLevel(maxLevel);
				boss.setMapId(mainMap.getMapId());
				boss.setX((short) 360);
				boss.setY((short) 240);
				boss.setName("三仙岛副本指引");
				boss.setBmpType(MmochatRoleBmpType.乞丐);
				boss.setFace(MmochatNpcFaceType.朝右);
				boss.getFunctionItems().add(MmochatNpcItemType.当前副本进度);
				boss.getFunctionItems().add(MmochatNpcItemType.本副本聊天指令);
				boss.getFunctionItems().add(MmochatNpcItemType.领取副本奖励);
				boss.getFunctionItems().add(MmochatNpcItemType.三仙岛副本介绍);
				boss.getFunctionItems().add(MmochatNpcItemType.前往江宁);
				npcs.put(boss.getNpcId(), boss);
				mainMap.addNpc(boss);

				// 小怪
				Short[][] points = new Short[][] { { 124, 106 }, { 153, 73 },
						{ 164, 136 }, { 128, 208 }, { 231, 216 }, { 298, 165 },
						{ 252, 274 }, { 136, 318 }, { 230, 386 }, { 191, 477 },
						{ 303, 425 }, { 435, 342 }, { 484, 246 }, { 419, 166 } };
				List<Short[]> pointList = new ArrayList<Short[]>();
				for (Short[] p : points) {
					pointList.add(p);
				}
				int monsterNum;
				if (fuBen.getType() == MmochatFuBenType.普通三仙岛) {
					monsterNum = 5;
				} else {
					monsterNum = 8;
				}
				for (int i = 0; i < monsterNum; i++) {
					int index = MmochatUtil.getRandomValue(pointList.size());
					Short[] point = pointList.remove(index);
					MmochatTempNpc monster = new MmochatTempNpc(true);
					monster.setLifeTime(fuBenTime);
					monster.setLine(me.getLine());
					monster.setLevel(maxLevel);
					monster.setMapId(mainMap.getMapId());
					monster.setX((short) point[0]);
					monster.setY((short) point[1]);
					monster.setName("小仙童");
					monster.setBmpType(MmochatRoleBmpType.儿童);
					monster.getFunctionItems().add(MmochatNpcItemType.挑战小仙童);
					npcs.put(monster.getNpcId(), monster);
					mainMap.addNpc(monster);
				}

				/******* 总坛 *******/
				subMap1.setMapDataId(49);
				subMap1.setCanChangeLine(false);
				subMap1.setWalkToBattle(false);
				subMap1.setCanTransToFriend(false);
				subMap1.setMapName("天绝");
				subMap1.getBattleOrders().add(MmochatBattleOrderType.隐身);
				// 传送点
				trans = new MmochatMapTransPoint();
				trans.setX(145);
				trans.setY(217);
				trans.setTransToMapId(mainMap.getMapId());
				trans.setNewMapX(445);
				trans.setNewMapY(189);
				subMap1.getTransPoints().add(trans);
				// npc
				boss = new MmochatTempNpc(true);
				boss.setLifeTime(fuBenTime);
				boss.setLine(me.getLine());
				boss.setLevel(maxLevel);
				boss.setMapId(subMap1.getMapId());
				boss.setX((short) 264);
				boss.setY((short) 121);
				boss.setName("天绝");
				boss.setBmpType(MmochatRoleBmpType.祖师爷);
				boss.setFace(MmochatNpcFaceType.朝左);
				boss.getFunctionItems().add(MmochatNpcItemType.挑战天绝);
				npcs.put(boss.getNpcId(), boss);
				subMap1.addNpc(boss);

				/******* 西厢 *******/
				subMap2.setMapDataId(48);
				subMap2.setCanChangeLine(false);
				subMap2.setWalkToBattle(false);
				subMap2.setCanTransToFriend(false);
				subMap2.setMapName("地灭");
				subMap2.getBattleOrders().add(MmochatBattleOrderType.隐身);
				// 传送点
				trans = new MmochatMapTransPoint();
				trans.setX(145);
				trans.setY(217);
				trans.setTransToMapId(mainMap.getMapId());
				trans.setNewMapX(358);
				trans.setNewMapY(141);
				subMap2.getTransPoints().add(trans);
				// npc
				boss = new MmochatTempNpc(true);
				boss.setLifeTime(fuBenTime);
				boss.setLine(me.getLine());
				boss.setLevel(maxLevel);
				boss.setMapId(subMap2.getMapId());
				boss.setX((short) 234);
				boss.setY((short) 133);
				boss.setName("地灭");
				boss.setBmpType(MmochatRoleBmpType.祖师爷);
				boss.setFace(MmochatNpcFaceType.朝左);
				boss.getFunctionItems().add(MmochatNpcItemType.挑战地灭);
				npcs.put(boss.getNpcId(), boss);
				subMap2.addNpc(boss);

				/******* 东厢 *******/
				subMap3.setMapDataId(50);
				subMap3.setCanChangeLine(false);
				subMap3.setWalkToBattle(false);
				subMap3.setCanTransToFriend(false);
				subMap3.setMapName("风生");
				subMap3.getBattleOrders().add(MmochatBattleOrderType.隐身);
				// 传送点
				trans = new MmochatMapTransPoint();
				trans.setX(145);
				trans.setY(217);
				trans.setTransToMapId(mainMap.getMapId());
				trans.setNewMapX(512);
				trans.setNewMapY(306);
				subMap3.getTransPoints().add(trans);
				// npc
				boss = new MmochatTempNpc(true);
				boss.setLifeTime(fuBenTime);
				boss.setLine(me.getLine());
				boss.setLevel(maxLevel);
				boss.setMapId(subMap3.getMapId());
				boss.setX((short) 236);
				boss.setY((short) 144);
				boss.setName("风生");
				boss.setBmpType(MmochatRoleBmpType.祖师爷);
				boss.setFace(MmochatNpcFaceType.朝左);
				boss.getFunctionItems().add(MmochatNpcItemType.挑战风生);
				npcs.put(boss.getNpcId(), boss);
				subMap3.addNpc(boss);

				// 进入副本
				MmochatMap curMap = MmochatMapService.getMapByMapId(me
						.getMapId());
				MmochatMap newMap = mainMap;
				MmochatMapService.tranToNewMap(curMap, me.getLine(), newMap, me
						.getLine(), fuBen.getEntryX(), fuBen.getEntryY(),
						members);
				for (MmochatPlayer member : members) {
					MmochatChatService
							.sendSystemMsgToPerson(
									member,
									"您花费了"
											+ MmochatUtil
													.getColorMoney(MmochatConstant.moneyNeedForSanXianDaoFuBen)
											+ "文钱进入了副本!");
				}
				break;
			}
			case 进入当前副本: {
				cleanTimeOutFuBenForRole(me);
				if (!me.isInFuBenActivity()) {
					return MmochatUtil.msgbox(req.getHallState(), "您还没有创建此副本!");
				}
				List<MmochatPlayer> members = new ArrayList<MmochatPlayer>();
				if (me.isInTeam()) {
					MmochatTeam team = MmochatTeamService.teams.get(me
							.getTeamId());
					if (team == null) {
						me.leaveTeam();
						members.add(me);
					} else {
						for (Integer roleId : team.getMemberId().values()) {
							MmochatPlayer member = MmochatMainService.players
									.get(roleId);
							if (member != null) {
								members.add(member);
							}
						}
					}
				} else {
					members.add(me);
				}
				for (MmochatPlayer member : members) {
					cleanTimeOutFuBenForRole(member);
					if (member.getFuBenId() != me.getFuBenId()) {
						return MmochatUtil.msgbox(req.getHallState(),
								MmochatUtil.wrapColor(member.getName(),
										Color.green)
										+ "与您不在同一个副本，无法一同进入!");
					}
				}

				MmochatFuBen fuBen = fuBens.get(me.getFuBenId());
				if (fuBen == null) {
					for (MmochatPlayer member : members) {
						member.leaveFuBen();
					}
					return MmochatUtil.msgbox(req.getHallState(),
							"此副本已过期，请重新创建副本!");
				}
				if (fuBen.getLine() != me.getLine()) {
					return MmochatUtil.msgbox(req.getHallState(), "此副本是在"
							+ (fuBen.getLine() + 1) + "线开启的，请从"
							+ (fuBen.getLine() + 1) + "线进入!");
				}
				// 进入副本
				MmochatMap curMap = MmochatMapService.getMapByMapId(me
						.getMapId());
				MmochatMap newMap = fuBen.getMaps().get(0);
				MmochatMapService.tranToNewMap(curMap, me.getLine(), newMap, me
						.getLine(), fuBen.getEntryX(), fuBen.getEntryY(),
						members);
				break;
			}
			case 放弃当前副本: {
				if (me.isInFuBenActivity()) {
					me.leaveFuBen();
					MmochatFuBen fuBen = fuBens.get(me.getFuBenId());
					if (fuBen != null) {
						fuBen.getOwners().remove((Integer) me.getRoleId());
						// 判断是否已经全部领取了奖励，领取后关闭地图
						if (fuBen.getOwners().size() == 0) {
							fuBen.close();
							fuBens.remove(fuBen.getId());
						}
					}
					return MmochatUtil.msgbox(req.getHallState(), "当前副本已放弃!");
				}
				return MmochatUtil.msgbox(req.getHallState(), "您当前没有副本!");
			}
			case 三仙岛副本介绍: {
				CreateTlvWin tlv = new CreateTlvWin();
				tlv.setWinType(WinType.Text);
				tlv.setRightName("返回");
				tlv.setTitle("三仙岛副本介绍");
				tlv.setWinHeight(188);
				tlv.addRightTLV(new CloseWinTLV());

				String content = "";
				content += MmochatUtil.wrapColor("[副本流程]", Color.yellow) + "\n";
				content += "此副本每天可以创建"
						+ MmochatDailyActivityType.三仙岛.getMaxDailyTimes()
						+ "次，放弃或超时未完成不计入次数。1~5人组队，"
						+ "到云中子处由队长创建三仙岛副本，创建时每人需要花费"
						+ MmochatUtil
								.getColorMoney(MmochatConstant.moneyNeedForSanXianDaoFuBen)
						+ "文钱，需要在2小时完成副本，超时则本次副本失败。先击杀三仙岛上的小仙童，"
						+ "杀完小仙童后再到房间里击杀地灭、天绝、风生三大仙。全部击杀后到副本指引处领取奖励。\n\n";
				content += MmochatUtil.wrapColor("[副本奖励]", Color.yellow) + "\n";
				content += "普通副本完成后可以获得"
						+ MmochatConstant.expAwardForSanXianDaoFuBen
						+ "次打怪经验，"
						+ MmochatConstant.daoAwardForSanXianDaoFuBen
						+ "天道行(人物道行高于标准道行奖励相应削减)和宠物武学，"
						+ "并有一定机率获得物品奖励。"
						+ MmochatUtil.wrapColor(
								"如果副本人数在3人或以上，且都是同一个帮派，则每人额外可以获得150点帮贡。",
								Color.magenta) + "高级副本是普通副本奖励的2倍。\n\n";
				content += MmochatUtil.wrapColor("[BOSS特点]", Color.yellow)
						+ "\n";
				content += "地灭、天绝、风生三仙各有特点:天绝伤害比其它两位高30%，地灭血量比其它两位高一倍，"
						+ "风生善于障碍。任意一仙被击杀后，剩余几位将继承它的特性。如地灭被击杀后，"
						+ "剩余存活的大仙血量将翻倍；天绝被击杀后，剩余存活的大仙伤害将提高30%，风生被击杀后，"
						+ "剩余存活的大仙增加25%的障碍机率。击杀顺序任意。\n\n";
				content += MmochatUtil.wrapColor("[BOSS绝技]", Color.yellow)
						+ "\n";
				content += "地灭、天绝、风生各有一招绝技，绝技在BOSS血量低于一定程度时，一定机率触发。"
						+ "在施放绝技前一回合，系统会通过战斗聊天进行通知。此绝技目标数10个，伤害非常大，"
						+ "被击中后没有生还的可能，但可能在绝技施放那一回合，发布聊天指令<隐身>进行闪避。\n\n";
				content += MmochatUtil.wrapColor("[聊天指令]", Color.yellow) + "\n";
				content += "聊天指令是在特定副本中使用的。只要在副本战斗中，发布战斗聊天消息，消息内容为指定的"
						+ "指令语，就可能实现一定的效果。如在三仙岛副本，可以使用：隐身。聊天指令效果只有一回合，"
						+ "下一回合效果自动消失。";

				tlv.setContent(new Text(content));
				return MmochatUtil.tlvResponse(req.getHallState(), tlv);
			}
			case 当前副本进度: {
				if (!me.isInFuBenActivity()) {
					return MmochatUtil.msgbox(req.getHallState(),
							"当前副本已过期，请退出重新创建!");
				}
				MmochatFuBen fuBen = fuBens.get(me.getFuBenId());
				if (fuBen == null) {
					return MmochatUtil.msgbox(req.getHallState(),
							"当前副本已过期，请退出重新创建!");
				}
				switch (fuBen.getType()) {
				case 普通三仙岛:
				case 高级三仙岛: {
					CreateTlvWin tlv = new CreateTlvWin();
					tlv.setWinType(WinType.Text);
					tlv.setRightName("返回");
					tlv.setTitle("当前副本进度");
					tlv.setWinHeight(188);
					tlv.addRightTLV(new CloseWinTLV());

					String content = "";
					content += MmochatUtil.wrapColor("[副本类型]", Color.yellow)
							+ "\n";
					content += fuBen.getType().toString() + "\n\n";
					content += MmochatUtil.wrapColor("[副本时间]", Color.yellow)
							+ "\n";
					SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
					String s = sdf.format(new Date(fuBen.getCreateTime()));
					String e = sdf.format(new Date(fuBen.getCreateTime()
							+ fuBen.getLifeTime()));
					int min = (int) ((fuBen.getCreateTime()
							+ fuBen.getLifeTime() - System.currentTimeMillis()) / MmochatConstant.MS_PER_MINUTE);
					content += "创建于" + s + "," + e + "时未完成则任务失败!当前还有" + min
							+ "分钟!\n\n";
					content += MmochatUtil.wrapColor("[当前任务]", Color.yellow)
							+ "\n";

					/*
					 * 0：室外 ；1：天绝：攻高 ；2：地灭：血高 ；3：风生：障碍
					 */
					int smallMonsterNum = 0;
					MmochatMap mainMap = fuBen.getMaps().get(0);
					if (mainMap != null) {
						int npcNum = mainMap.getLineNpcMap(me.getLine()).size();
						if (npcNum > 1) {
							smallMonsterNum = npcNum;
						}
					}
					if (smallMonsterNum > 1) {
						content += "击杀小仙童!当前三仙岛上还有" + (smallMonsterNum - 1)
								+ "个小仙童!\n";
					} else {
						MmochatMap subMap = fuBen.getMaps().get(1);
						if (subMap != null
								&& subMap.getLineNpcMap(me.getLine()).size() > 0) {
							content += "击杀天绝、地灭、风生。天绝伤害比其它两位高30%，地灭血量比其它两位高一倍，"
									+ "风生善于障碍。任意其中一位被击杀后，剩余几位将继承它的特性。如地灭被击杀后，"
									+ "剩余存活的大仙血量将翻倍。击杀顺序随意!";
						} else {
							subMap = fuBen.getMaps().get(2);
							if (subMap != null
									&& subMap.getLineNpcMap(me.getLine())
											.size() > 0) {
								content += "击杀天绝、地灭、风生。天绝伤害比其它两位高30%，地灭血量比其它两位高一倍，"
										+ "风生善于障碍。任意其中一位被击杀后，剩余几位将继承它的特性。如地灭被击杀后，"
										+ "剩余存活的大仙血量将翻倍。击杀顺序随意!";
							} else {
								subMap = fuBen.getMaps().get(3);
								if (subMap != null
										&& subMap.getLineNpcMap(me.getLine())
												.size() > 0) {
									content += "击杀天绝、地灭、风生。天绝伤害比其它两位高30%，地灭血量比其它两位高一倍，"
											+ "风生善于障碍。任意其中一位被击杀后，剩余几位将继承它的特性。如地灭被击杀后，"
											+ "剩余存活的大仙血量将翻倍。击杀顺序随意!";
								} else {
									content += "任务已完成!找<三仙岛副本指引>领取副本奖励!";
								}
							}
						}
					}
					tlv.setContent(new Text(content));
					return MmochatUtil.tlvResponse(req.getHallState(), tlv);
				}
				default:
					return MmochatUtil.msgbox(req.getHallState(),
							"副本类型错误，请联系客服!");
				}
			}
			case 领取副本奖励: {
				if (!me.isInFuBenActivity()) {
					return MmochatUtil.msgbox(req.getHallState(),
							"当前副本已过期，请退出重新创建!");
				}
				MmochatFuBen fuBen = fuBens.get(me.getFuBenId());
				if (fuBen == null) {
					return MmochatUtil.msgbox(req.getHallState(),
							"当前副本已过期，请退出重新创建!");
				}
				switch (fuBen.getType()) {
				case 普通三仙岛:
				case 高级三仙岛: {
					/*
					 * 0：室外 ；1：天绝：攻高 ；2：地灭：血高 ；3：风生：障碍
					 */
					MmochatMap mainMap = fuBen.getMaps().get(0);
					if (mainMap != null) {
						int npcNum = mainMap.getLineNpcMap(me.getLine()).size();
						if (npcNum > 1) {
							return MmochatUtil.msgbox(req.getHallState(),
									"当前室外还有"
											+ MmochatUtil.wrapColor(
													(npcNum - 1) + "个",
													Color.yellow)
											+ "小仙童，请先去和他们过下招吧!");
						}
					}
					MmochatMap subMap = fuBen.getMaps().get(1);
					if (subMap != null
							&& subMap.getLineNpcMap(me.getLine()).size() > 0) {
						return MmochatUtil.msgbox(req.getHallState(),
								"您还没有将天绝、地灭、风生三仙全部击倒，还不能领取奖励!");
					}
					subMap = fuBen.getMaps().get(2);
					if (subMap != null
							&& subMap.getLineNpcMap(me.getLine()).size() > 0) {
						return MmochatUtil.msgbox(req.getHallState(),
								"您还没有将天绝、地灭、风生三仙全部击倒，还不能领取奖励!");
					}
					subMap = fuBen.getMaps().get(3);
					if (subMap != null
							&& subMap.getLineNpcMap(me.getLine()).size() > 0) {
						return MmochatUtil.msgbox(req.getHallState(),
								"您还没有将天绝、地灭、风生三仙全部击倒，还不能领取奖励!");
					}
					List<MmochatPlayer> members = new ArrayList<MmochatPlayer>();
					if (me.isInTeam()) {
						MmochatTeam team = MmochatTeamService.teams.get(me
								.getTeamId());
						if (team == null) {
							me.leaveTeam();
							members.add(me);
						} else {
							for (Integer roleId : team.getMemberId().values()) {
								MmochatPlayer member = MmochatMainService.players
										.get(roleId);
								if (member != null) {
									members.add(member);
								}
							}
							// 解散队伍
							team.dismissTeam();
						}
					} else {
						members.add(me);
					}

					// 向队伍其它成员发出通知
					for (MmochatPlayer member : members) {
						if (member.getRoleId() != me.getRoleId()) {
							MmochatUtil.sendCommonMsgbox(member,
									"副本完成，请找<三仙岛副本指引>领取奖励!");
							MmochatChatService.sendSystemMsgToPerson(member,
									"副本完成，请找<三仙岛副本指引>领取奖励!");
						}
					}

					synchronized (me) {
						// 领取奖励；领取后从当前副本成员中移除
						if (!fuBen.getOwners().contains(me.getRoleId())) {
							return MmochatUtil.msgbox(req.getHallState(),
									"您已经领取了奖励!");
						}

						// 增加今天副本次数
						MmochatDailyActivity activity = me.getDailyActivities()
								.get(MmochatDailyActivityType.三仙岛);
						if (activity == null) {
							// 第一次参加此活动
							activity = new MmochatDailyActivity();
							activity.setType(MmochatDailyActivityType.三仙岛);
							me.addDailyActivity(activity);
						}
						Date now = new Date();
						Date lastDate = new Date(activity.getLastTime());
						if (now.getDate() == lastDate.getDate()
								&& now.getMonth() == lastDate.getMonth()
								&& now.getYear() == lastDate.getYear()) {
							// 今天参加过
							activity.addDailyTimes(1);
						} else {
							// 今天没参加过
							activity.setLastTime(now.getTime());
							activity.setDailyTimes(1);
						}

						// TODO:发放奖励
						String awardInfo = "";
						int exp = 0, dao = 0, gangAward = 0, petDao = 0;
						int initDao = 0;// 削减前的道行
						int equipPercent = 0;
						MmochatPet pet = me.getPkPet();
						Map<MmochatRoleAttributeType, Double> attrMap = MmochatPetService.monsterBaseAttackData
								.get(me.getTrueLevel());
						if (fuBen.getType() == MmochatFuBenType.普通三仙岛) {
							// 300倍野怪经验 3000天道行 150帮贡
							if (attrMap != null) {
								exp = (int) (attrMap
										.get(MmochatRoleAttributeType.杀死怪物经验) * MmochatConstant.expAwardForSanXianDaoFuBen);
							}
							initDao = MmochatConstant.daoAwardForSanXianDaoFuBen;
							dao = MmochatBattleService.getRealDao(me,
									MmochatConstant.daoAwardForSanXianDaoFuBen);
							petDao = MmochatConstant.daoAwardForSanXianDaoFuBen;
							equipPercent = 30;
							gangAward = MmochatConstant.gangAwardForSanXianDaoFuBen;
						} else {
							// 600倍野怪经验 6000天道行 300帮贡
							if (attrMap != null) {
								exp = (int) (attrMap
										.get(MmochatRoleAttributeType.杀死怪物经验)
										* MmochatConstant.expAwardForSanXianDaoFuBen * 2);
							}
							initDao = MmochatConstant.daoAwardForSanXianDaoFuBen * 2;
							dao = MmochatBattleService
									.getRealDao(
											me,
											MmochatConstant.daoAwardForSanXianDaoFuBen * 2);
							petDao = MmochatConstant.daoAwardForSanXianDaoFuBen * 2;
							equipPercent = 60;
							gangAward = MmochatConstant.gangAwardForSanXianDaoFuBen * 2;
						}
						boolean uplevel = false;
						if (exp > 0) {
							uplevel = me.addExp(exp);
							awardInfo += exp + "点经验!";
							if (uplevel) {
								awardInfo += "您升级 了!";
							}

							if (pet != null) {
								if (pet.getLevel() >= me.getTrueLevel()
										+ MmochatConstant.zeroAwardOfPetLevelMoreThanOwner) {
									awardInfo += "你的"
											+ pet.getName()
											+ "高于你"
											+ MmochatConstant.zeroAwardOfPetLevelMoreThanOwner
											+ "级,无法获得经验!";
								} else {
									int petExp = MmochatBattleService
											.getRealExp2(exp, pet, me
													.getTrueLevel());
									boolean petUplevel = pet.addExp(me, petExp);
									awardInfo += "你的" + pet.getName() + "获得了"
											+ petExp + "点经验!";
									if (petUplevel) {
										awardInfo += "你的" + pet.getName()
												+ "升级了!";
									}
								}
							}
						}
						if (dao > 0) {
							// 刷道比赛
							MmochatPropService.dealDaoActivity(me, initDao);

							me.addDao(dao);
							awardInfo += dao + "天道行(削减前" + initDao + "天)!";
							if (pet != null) {
								int totalDao = MmochatBattleService
										.getRealDaoOfLevel2(petDao, pet, me
												.getTrueLevel());
								petDao = MmochatBattleService.getRealDao(pet,
										totalDao);
								pet.addDao(petDao);
								awardInfo += "你的" + pet.getName() + "获得了"
										+ petDao + "点武学!";
							}
						}

						for (int i = 0; i < 3; i++) {
							if (!MmochatUtil.isInPercent(equipPercent)) {
								continue;
							}
							MmochatEquip equip = MmochatEquipService
									.getRandEquip(me.getTrueLevel(), me
											.getTrueLevel() + 10, 0, 0, 100);
							if (equip != null) {
								boolean success = me.addObjectToPackage(equip);
								if (success) {
									awardInfo += "一件"
											+ MmochatUtil.wrapColor(equip
													.getName(), equip
													.getQuality().getColor())
											+ "!";
								} else {
									awardInfo += "您的包裹已满,无法获得"
											+ equip.getName() + "!";
								}
							}
						}
						if (fuBen.isGangFuBen() && gangAward > 0) {
							MmochatGang gang = MmochatGangService
									.getGangById(me.getGangId());
							if (gang != null) {
								MmochatGangMember member = gang.getMembers()
										.get(me.getRoleId());
								if (member != null) {
									member.addBuildValue(gangAward);
									gang.addBuildValue(gangAward);
									awardInfo += gangAward + "点帮派贡献度和建设度!";
									try {
										MmochatDao.updateAfterGangTask(gang,
												gangAward, 0);
									} catch (Exception e) {
										e.printStackTrace();
									}
								}
							}
						}

						// 更新头像图标信息
						Mmochat_1_7S pack = new Mmochat_1_7S(uplevel);
						pack.setMe(me);
						MmochatUtil.sendCommonPack(me, pack);
						if (awardInfo.length() > 0) {
							MmochatChatService.sendSystemMsgToPerson(me, "你获得了"
									+ awardInfo);
						}
					}

					// 送出地图
					me.leaveFuBen();
					MmochatMap curMap = MmochatMapService.getMapByMapId(me
							.getMapId());
					MmochatMap newMap = MmochatMapService.getMapByMapId(4);
					MmochatMapService.tranToNewMap(curMap, me.getLine(),
							newMap, me.getLine(), 80, 708, me);

					// 保存数据库:dailyActivity,包裹,经验,道行,宠物等
					try {
						MmochatDao.updateRoleAfterFuBen(me);
					} catch (Exception e) {
						e.printStackTrace();
					}
					break;
				}
				default:
					break;
				}
				synchronized (fuBen) {
					// 判断是否已经全部领取了奖励，领取后关闭地图
					fuBen.getOwners().remove((Integer) me.getRoleId());
					if (fuBen.getOwners().size() == 0) {
						fuBen.close();
						fuBens.remove(fuBen.getId());
					}
				}
				break;
			}
			case 本副本聊天指令: {
				if (!me.isInFuBenActivity()) {
					return MmochatUtil.msgbox(req.getHallState(),
							"当前副本已过期，请退出重新创建!");
				}
				MmochatFuBen fuBen = fuBens.get(me.getFuBenId());
				if (fuBen == null) {
					return MmochatUtil.msgbox(req.getHallState(),
							"当前副本已过期，请退出重新创建!");
				}
				switch (fuBen.getType()) {
				case 普通三仙岛:
				case 高级三仙岛: {
					CreateTlvWin tlv = new CreateTlvWin();
					tlv.setWinType(WinType.Text);
					tlv.setRightName("返回");
					tlv.setTitle("本副本聊天指令");
					tlv.setWinHeight(188);
					tlv.addRightTLV(new CloseWinTLV());
					String content = "";
					content += MmochatUtil.wrapColor("[有效指令]", Color.yellow)
							+ "\n";
					content += MmochatBattleOrderType.隐身.toString() + "\n\n";
					content += MmochatUtil.wrapColor("[如何使用指令]", Color.yellow)
							+ "\n";
					content += "在战斗中，通过战斗聊天，发送相应的聊天内容即可。如发送聊天内容：隐身，就可以"
							+ "设置下一回合进入隐身状态。\n\n";
					content += MmochatUtil.wrapColor("[指令效果]", Color.yellow)
							+ "\n";
					content += MmochatUtil.wrapColor(MmochatBattleOrderType.隐身
							.toString(), Color.green)
							+ ":可以100%抵挡BOSS绝技：神级五毒缠身、神级五雷轰顶、神级冥河黑水，但在隐身状态下，"
							+ "也无法进行物攻、法术、障碍技能的使用。";

					tlv.setContent(new Text(content));
					return MmochatUtil.tlvResponse(req.getHallState(), tlv);
				}
				default:
					break;
				}
				break;
			}
			case 挑战小仙童: {
				if (!me.isInFuBenActivity()) {
					return MmochatUtil.msgbox(req.getHallState(),
							"当前副本已过期，请退出重新创建!");
				}
				MmochatFuBen fuBen = fuBens.get(me.getFuBenId());
				if (fuBen == null) {
					return MmochatUtil.msgbox(req.getHallState(),
							"当前副本已过期，请退出重新创建!");
				}
				MmochatBattleModelType battleType;
				switch (fuBen.getType()) {
				case 普通三仙岛:
					battleType = MmochatBattleModelType.普通三仙岛之小怪;
					break;
				case 高级三仙岛:
					battleType = MmochatBattleModelType.高级三仙岛之小怪;
					break;
				default:
					return MmochatUtil.msgbox(req.getHallState(),
							"此副本不能挑战小仙童，请联系客服处理!");
				}
				List<MmochatPlayer> members = new ArrayList<MmochatPlayer>();
				if (me.isInTeam()) {
					MmochatTeam team = MmochatTeamService.teams.get(me
							.getTeamId());
					if (team == null) {
						me.leaveTeam();
						members.add(me);
					} else {
						for (Integer roleId : team.getMemberId().values()) {
							MmochatPlayer member = MmochatMainService
									.getRoleFromBuffer(roleId);
							if (member != null) {
								members.add(member);
							}
						}
					}
				} else {
					members.add(me);
				}

				MmochatNpcBattle battle = MmochatMainService
						.getBattleModelByType(battleType);
				if (battle == null) {
					return MmochatUtil.msgbox(req.getHallState(),
							"目标无法战斗，请联系客服!");
				}
				MmochatTask task = new MmochatTask();
				task.setTaskType(MmochatTaskType.击杀无奖励临时怪物);
				task.setFinish_need_battles(battle);

				// 进入战斗
				MmochatTempNpc activeNpc = (MmochatTempNpc) npc;
				synchronized (activeNpc) {
					if (activeNpc.getState() == MmochatNpcState.空闲) {
						activeNpc.setState(MmochatNpcState.战斗中);
					} else if (activeNpc.getState() == MmochatNpcState.离开) {
						return MmochatUtil
								.msgbox(req.getHallState(), "目标已经离开!");
					} else if (activeNpc.getState() == MmochatNpcState.战斗中) {
						return MmochatUtil.msgbox(req.getHallState(),
								"目标正在战斗中,请稍候再来!");
					}
				}
				MmochatBattleService.enterNpcPk(me.getMapId(), (byte) me
						.getLine(), members, me.getRoleId(), task, req
						.getNpcId());

				break;
			}
			case 挑战天绝: {
				if (!me.isInFuBenActivity()) {
					return MmochatUtil.msgbox(req.getHallState(),
							"当前副本已过期，请退出重新创建!");
				}
				MmochatFuBen fuBen = fuBens.get(me.getFuBenId());
				if (fuBen == null) {
					return MmochatUtil.msgbox(req.getHallState(),
							"当前副本已过期，请退出重新创建!");
				}
				/*
				 * 0：室外 ；1：天绝：攻高 ；2：地灭：血高 ；3：风生：障碍
				 */
				MmochatMap mainMap = fuBen.getMaps().get(0);
				if (mainMap != null) {
					int npcNum = mainMap.getLineNpcMap(me.getLine()).size();
					if (npcNum > 1) {
						return MmochatUtil.msgbox(req.getHallState(), "当前室外还有"
								+ MmochatUtil.wrapColor((npcNum - 1) + "个",
										Color.yellow) + "小仙童，请先去和他们过下招吧!");
					}
				}
				boolean addAttack = false, addBlood = false, addLimit = false;
				// 天绝，攻+30%
				addAttack = true;

				MmochatMap subMap = fuBen.getMaps().get(2);
				if (subMap != null
						&& subMap.getLineNpcMap(me.getLine()).size() == 0) {
					// 地灭挂了，血加倍
					addBlood = true;
				}

				subMap = fuBen.getMaps().get(3);
				if (subMap != null
						&& subMap.getLineNpcMap(me.getLine()).size() == 0) {
					// 风生挂了，提高障碍机率
					addLimit = true;
				}

				// 进入战斗
				List<MmochatPlayer> members = new ArrayList<MmochatPlayer>();
				if (me.isInTeam()) {
					MmochatTeam team = MmochatTeamService.teams.get(me
							.getTeamId());
					if (team == null) {
						me.leaveTeam();
						members.add(me);
					} else {
						for (Integer roleId : team.getMemberId().values()) {
							MmochatPlayer member = MmochatMainService
									.getRoleFromBuffer(roleId);
							if (member != null) {
								members.add(member);
							}
						}
					}
				} else {
					members.add(me);
				}

				MmochatBattleModelType battleType;
				switch (fuBen.getType()) {
				case 普通三仙岛:
					battleType = MmochatBattleModelType.普通三仙岛之天绝;
					break;
				case 高级三仙岛:
					battleType = MmochatBattleModelType.高级三仙岛之天绝;
					break;
				default:
					return MmochatUtil.msgbox(req.getHallState(),
							"此副本不能挑战天绝，请联系客服处理!");
				}
				MmochatNpcBattle battle = MmochatMainService
						.getBattleModelByType(battleType);
				if (battle == null) {
					return MmochatUtil.msgbox(req.getHallState(),
							"目标无法战斗，请联系客服!");
				}
				MmochatMonsterFactory boss = battle.getBoss();
				if (addAttack) {
					// 加攻30%
					boss.setPhysical(boss.getPhysical() * 1.3);
					boss.setMagic(boss.getMagic() * 1.3);
				}
				if (addBlood) {
					// 加血100%
					boss.setKillRound(boss.getKillRound() * 2);
				}
				if (addLimit) {
					// 物攻机率减25%,障碍机率加25%
					MmochatAttackModeOfNormal attackMode_normal = boss
							.getAttackMode_normal();
					if (attackMode_normal != null) {
						attackMode_normal
								.setPhysicalAttackOpportunity(attackMode_normal
										.getPhysicalAttackOpportunity() - 25);
						attackMode_normal.setLimitOppotunity(attackMode_normal
								.getLimitOppotunity() + 25);
					}
				}

				MmochatTask task = new MmochatTask();
				task.setTaskType(MmochatTaskType.击杀无奖励临时怪物);
				task.setFinish_need_battles(battle);

				// 进入战斗
				MmochatTempNpc activeNpc = (MmochatTempNpc) npc;
				synchronized (activeNpc) {
					if (activeNpc.getState() == MmochatNpcState.空闲) {
						activeNpc.setState(MmochatNpcState.战斗中);
					} else if (activeNpc.getState() == MmochatNpcState.离开) {
						return MmochatUtil
								.msgbox(req.getHallState(), "目标已经离开!");
					} else if (activeNpc.getState() == MmochatNpcState.战斗中) {
						return MmochatUtil.msgbox(req.getHallState(),
								"目标正在战斗中,请稍候再来!");
					}
				}
				MmochatBattleService.enterNpcPk(me.getMapId(), (byte) me
						.getLine(), members, me.getRoleId(), task, req
						.getNpcId());

				break;

			}
			case 挑战地灭: {
				if (!me.isInFuBenActivity()) {
					return MmochatUtil.msgbox(req.getHallState(),
							"当前副本已过期，请退出重新创建!");
				}
				MmochatFuBen fuBen = fuBens.get(me.getFuBenId());
				if (fuBen == null) {
					return MmochatUtil.msgbox(req.getHallState(),
							"当前副本已过期，请退出重新创建!");
				}
				/*
				 * 0：室外 ；1：天绝：攻高 ；2：地灭：血高 ；3：风生：障碍
				 */
				MmochatMap mainMap = fuBen.getMaps().get(0);
				if (mainMap != null) {
					int npcNum = mainMap.getLineNpcMap(me.getLine()).size();
					if (npcNum > 1) {
						return MmochatUtil.msgbox(req.getHallState(), "当前室外还有"
								+ MmochatUtil.wrapColor((npcNum - 1) + "个",
										Color.yellow) + "小仙童，请先去和他们过下招吧!");
					}
				}
				boolean addAttack = false, addBlood = false, addLimit = false;
				// 地灭：血高
				addBlood = true;

				MmochatMap subMap = fuBen.getMaps().get(1);
				if (subMap != null
						&& subMap.getLineNpcMap(me.getLine()).size() == 0) {
					// 天绝：攻高
					addAttack = true;
				}

				subMap = fuBen.getMaps().get(3);
				if (subMap != null
						&& subMap.getLineNpcMap(me.getLine()).size() == 0) {
					// 风生挂了，提高障碍机率
					addLimit = true;
				}

				// 进入战斗
				List<MmochatPlayer> members = new ArrayList<MmochatPlayer>();
				if (me.isInTeam()) {
					MmochatTeam team = MmochatTeamService.teams.get(me
							.getTeamId());
					if (team == null) {
						me.leaveTeam();
						members.add(me);
					} else {
						for (Integer roleId : team.getMemberId().values()) {
							MmochatPlayer member = MmochatMainService
									.getRoleFromBuffer(roleId);
							if (member != null) {
								members.add(member);
							}
						}
					}
				} else {
					members.add(me);
				}
				MmochatBattleModelType battleType;
				switch (fuBen.getType()) {
				case 普通三仙岛:
					battleType = MmochatBattleModelType.普通三仙岛之地灭;
					break;
				case 高级三仙岛:
					battleType = MmochatBattleModelType.高级三仙岛之地灭;
					break;
				default:
					return MmochatUtil.msgbox(req.getHallState(),
							"此副本不能挑战天绝，请联系客服处理!");
				}
				MmochatNpcBattle battle = MmochatMainService
						.getBattleModelByType(battleType);
				if (battle == null) {
					return MmochatUtil.msgbox(req.getHallState(),
							"目标无法战斗，请联系客服!");
				}
				MmochatMonsterFactory boss = battle.getBoss();
				if (addAttack) {
					// 加攻30%
					boss.setPhysical(boss.getPhysical() * 1.3);
					boss.setMagic(boss.getMagic() * 1.3);
				}
				if (addBlood) {
					// 加血100%
					boss.setKillRound(boss.getKillRound() * 2);
				}
				if (addLimit) {
					// 物攻机率减25%,障碍机率加25%
					MmochatAttackModeOfNormal attackMode_normal = boss
							.getAttackMode_normal();
					if (attackMode_normal != null) {
						attackMode_normal
								.setPhysicalAttackOpportunity(attackMode_normal
										.getPhysicalAttackOpportunity() - 25);
						attackMode_normal.setLimitOppotunity(attackMode_normal
								.getLimitOppotunity() + 25);
					}
				}

				MmochatTask task = new MmochatTask();
				task.setTaskType(MmochatTaskType.击杀无奖励临时怪物);
				task.setFinish_need_battles(battle);

				// 进入战斗
				MmochatTempNpc activeNpc = (MmochatTempNpc) npc;
				synchronized (activeNpc) {
					if (activeNpc.getState() == MmochatNpcState.空闲) {
						activeNpc.setState(MmochatNpcState.战斗中);
					} else if (activeNpc.getState() == MmochatNpcState.离开) {
						return MmochatUtil
								.msgbox(req.getHallState(), "目标已经离开!");
					} else if (activeNpc.getState() == MmochatNpcState.战斗中) {
						return MmochatUtil.msgbox(req.getHallState(),
								"目标正在战斗中,请稍候再来!");
					}
				}
				MmochatBattleService.enterNpcPk(me.getMapId(), (byte) me
						.getLine(), members, me.getRoleId(), task, req
						.getNpcId());

				break;

			}
			case 挑战风生: {
				if (!me.isInFuBenActivity()) {
					return MmochatUtil.msgbox(req.getHallState(),
							"当前副本已过期，请退出重新创建!");
				}
				MmochatFuBen fuBen = fuBens.get(me.getFuBenId());
				if (fuBen == null) {
					return MmochatUtil.msgbox(req.getHallState(),
							"当前副本已过期，请退出重新创建!");
				}
				/*
				 * 0：室外 ；1：天绝：攻高 ；2：地灭：血高 ；3：风生：障碍
				 */
				MmochatMap mainMap = fuBen.getMaps().get(0);
				if (mainMap != null) {
					int npcNum = mainMap.getLineNpcMap(me.getLine()).size();
					if (npcNum > 1) {
						return MmochatUtil.msgbox(req.getHallState(), "当前室外还有"
								+ MmochatUtil.wrapColor((npcNum - 1) + "个",
										Color.yellow) + "小仙童，请先去和他们过下招吧!");
					}
				}
				boolean addAttack = false, addBlood = false, addLimit = false;
				// 风生：障碍
				addLimit = true;

				MmochatMap subMap = fuBen.getMaps().get(1);
				if (subMap != null
						&& subMap.getLineNpcMap(me.getLine()).size() == 0) {
					// 天绝：攻高
					addAttack = true;
				}

				subMap = fuBen.getMaps().get(2);
				if (subMap != null
						&& subMap.getLineNpcMap(me.getLine()).size() == 0) {
					// 地灭挂了，血加倍
					addBlood = true;
				}

				// 进入战斗
				List<MmochatPlayer> members = new ArrayList<MmochatPlayer>();
				if (me.isInTeam()) {
					MmochatTeam team = MmochatTeamService.teams.get(me
							.getTeamId());
					if (team == null) {
						me.leaveTeam();
						members.add(me);
					} else {
						for (Integer roleId : team.getMemberId().values()) {
							MmochatPlayer member = MmochatMainService
									.getRoleFromBuffer(roleId);
							if (member != null) {
								members.add(member);
							}
						}
					}
				} else {
					members.add(me);
				}
				MmochatBattleModelType battleType;
				switch (fuBen.getType()) {
				case 普通三仙岛:
					battleType = MmochatBattleModelType.普通三仙岛之风生;
					break;
				case 高级三仙岛:
					battleType = MmochatBattleModelType.高级三仙岛之风生;
					break;
				default:
					return MmochatUtil.msgbox(req.getHallState(),
							"此副本不能挑战天绝，请联系客服处理!");
				}
				MmochatNpcBattle battle = MmochatMainService
						.getBattleModelByType(battleType);
				if (battle == null) {
					return MmochatUtil.msgbox(req.getHallState(),
							"目标无法战斗，请联系客服!");
				}
				MmochatMonsterFactory boss = battle.getBoss();
				if (addAttack) {
					// 加攻30%
					boss.setPhysical(boss.getPhysical() * 1.3);
					boss.setMagic(boss.getMagic() * 1.3);
				}
				if (addBlood) {
					// 加血100%
					boss.setKillRound(boss.getKillRound() * 2);
				}
				if (addLimit) {
					// 物攻机率减25%,障碍机率加25%
					MmochatAttackModeOfNormal attackMode_normal = boss
							.getAttackMode_normal();
					if (attackMode_normal != null) {
						attackMode_normal
								.setPhysicalAttackOpportunity(attackMode_normal
										.getPhysicalAttackOpportunity() - 25);
						attackMode_normal.setLimitOppotunity(attackMode_normal
								.getLimitOppotunity() + 25);
					}
				}

				MmochatTask task = new MmochatTask();
				task.setTaskType(MmochatTaskType.击杀无奖励临时怪物);
				task.setFinish_need_battles(battle);

				// 进入战斗
				MmochatTempNpc activeNpc = (MmochatTempNpc) npc;
				synchronized (activeNpc) {
					if (activeNpc.getState() == MmochatNpcState.空闲) {
						activeNpc.setState(MmochatNpcState.战斗中);
					} else if (activeNpc.getState() == MmochatNpcState.离开) {
						return MmochatUtil
								.msgbox(req.getHallState(), "目标已经离开!");
					} else if (activeNpc.getState() == MmochatNpcState.战斗中) {
						return MmochatUtil.msgbox(req.getHallState(),
								"目标正在战斗中,请稍候再来!");
					}
				}
				MmochatBattleService.enterNpcPk(me.getMapId(), (byte) me
						.getLine(), members, me.getRoleId(), task, req
						.getNpcId());

				break;

			}
			case 比武场说明: {
				CreateTlvWin tlv = new CreateTlvWin();
				tlv.setWinType(WinType.Text);
				tlv.setRightName("返回");
				tlv.setTitle("比武场说明");
				tlv.setWinHeight(188);
				tlv.addRightTLV(new CloseWinTLV());
				String content = "";
				content += MmochatUtil.wrapColor("[挑战规则]", Color.green);
				content += "\n自由组队，队伍中每人战绩都要不低于1000点战绩。点击其它场内玩家进行切磋，即可发起挑战。"
						+ "场内挑战需要经过双方同意。战败方扣除一定战绩，胜利方平分这些战绩。"
						+ "扣除的战绩量取决于两支队伍的综合实力差距。实力强的战败，扣除的战绩较多，"
						+ "实力弱的战败，扣除的战绩较少。\n\n";

				tlv.setContent(new Text(content));
				return MmochatUtil.tlvResponse(req.getHallState(), tlv);
			}
			case 横扫千军技能:
			case 一击必杀技能:
			case 道法无边技能: {
				CreateTlvWin tlv = new CreateTlvWin();
				tlv.setWinType(WinType.List);
				tlv.setLeftName("查看");
				tlv.setRightName("返回");
				tlv.setTitle(type.toString());
				tlv.setWinHeight(188);
				tlv.addRightTLV(new CloseWinTLV());

				tlv.addItemEvent("查看我的技能", new ClearDataTLV(), new AddDataTLV(
						(int) 1));
				tlv.addItemEvent("技能介绍", new ClearDataTLV(), new AddDataTLV(
						(int) 2));
				tlv.addItemEvent("熟练度训练", new ClearDataTLV(), new AddDataTLV(
						(int) 3));

				MmochatSpecialSkillType skillType;
				switch (type) {
				case 横扫千军技能:
					skillType = MmochatSpecialSkillType.横扫千军;
					break;
				case 一击必杀技能:
					skillType = MmochatSpecialSkillType.一击必杀;
					break;
				case 道法无边技能:
				default:
					skillType = MmochatSpecialSkillType.道法无边;
					break;
				}
				tlv.addLeftTLV(new AddDataTLV((int) skillType.getValue()));
				tlv.addLeftTLV(new SendDataTLV(MmochatConstant
						.getClientModuleId(), MmochatMain.getModuleInstID(),
						MmochatConstant.MSGCODE_MMOCHAT_C_9_51, (int) me
								.getRoleId()));
				tlv.addLeftTLV(new ShowWaitingMsgBoxTLV());

				return MmochatUtil.tlvResponse(req.getHallState(), tlv);
			}
			default:
				break;
			}
			return null;
		}
	}

	@SuppressWarnings( { "deprecation", "unchecked" })
	public static SkymobiProtocolMessage dealHandleC_9_1_sub1(
			MmochatNpcItemType type, MmochatNpc npc, Mmochat_9_1C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return null;
		}
		switch (type) {
		case 领取VIP双倍: {
			if (me.hasPropEffect(MmochatPropType.会员周卡.getEffectKey())) {
				long timeBak;
				synchronized (me) {
					Date lastDate = new Date(me.getLastGetVipDoublePropTime());
					Date now = new Date();
					if (now.getYear() == lastDate.getYear()
							&& now.getMonth() == lastDate.getMonth()
							&& now.getDate() == lastDate.getDate()) {
						MmochatPropEffect effect = me.getPropEffects().get(
								MmochatPropType.会员周卡.getEffectKey());
						long vipStartTime = effect.getStartTime();
						long lastUseTime = me.getLastGetVipDoublePropTime();
						if (lastUseTime >= vipStartTime) {
							return MmochatUtil.msgbox(req.getHallState(),
									"您今天已经领过双倍了,一天只能领一次噢,请明天再来!");
						}
					}
					timeBak = me.getLastGetVipDoublePropTime();
					me.setLastGetVipDoublePropTime(now.getTime());

					MmochatPropEffect effect = me.getPropEffects().get(
							MmochatPropType.天尊令.getEffectKey());
					if (effect != null) {
						effect.addAmount(MmochatConstant.MS_PER_HOUR);
					} else {
						effect = new MmochatPropEffect();
						effect.setPropType(MmochatPropType.天尊令);
						effect.setRestAmount(MmochatConstant.MS_PER_HOUR);
						me.addPropEffect(effect);
					}

					try {
						MmochatDao.updateRoleGetVipDouble(me);
						return MmochatUtil.msgbox(req.getHallState(),
								"您领取了1小时双倍时间!按左软键查看道具状态,可查看双倍剩余时间");
					} catch (Exception e) {
						e.printStackTrace();
						me.setLastGetVipDoublePropTime(timeBak);
						effect.addAmount(-1 * MmochatConstant.MS_PER_HOUR);
						if (effect.getRestAmount() <= 0) {
							me
									.delPropEffect(MmochatPropType.天尊令
											.getEffectKey());
						}
						return MmochatUtil.msgbox(req.getHallState(),
								"服务器忙,请稍候再试!");
					}
				}
			} else {
				return MmochatUtil.msgbox(req.getHallState(),
						"只有会员才能每天来我这里领取双倍噢!按9键打开商城即可购买会员卡。");
			}

		}
		case 新手免费洗点: {
			boolean isFreeDay = false;
			if (MmochatTempActivityService.freePointDay != null
					&& MmochatTempActivityService.freePointDay.length > 0) {
				// 全民免费洗点
				long curTick = System.currentTimeMillis();
				for (int i = 0; i < MmochatTempActivityService.freePointDay.length; i++) {
					String startDate = MmochatTempActivityService.freePointDay[i];
					SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
					Date start = null;
					try {
						start = sdf.parse(startDate);
					} catch (ParseException e) {
						continue;
					}
					if (curTick >= start.getTime()
							&& curTick < start.getTime()
									+ MmochatConstant.MS_PER_DAY) {
						isFreeDay = true;
						break;
					}
				}
			}
			String hint;
			if (isFreeDay) {
				hint = "今天全民可以免费洗点!您确定要"
						+ MmochatUtil.wrapColor("洗去人物所有属性点和天赋点", Color.green)
						+ ",并重新分配么?";
			} else {
				if (me.getLevel() > MmochatConstant.getMaxLevelToFreeSetPoint()) {
					return MmochatUtil.msgbox(req.getHallState(), "只有"
							+ MmochatConstant.getMaxLevelToFreeSetPoint()
							+ "级以前的新手才能到我这免费洗点。您的修为过高,我已无能为力!");
				}
				hint = "不超过" + MmochatConstant.getMaxLevelToFreeSetPoint()
						+ "级的新手可到我这免费洗点。您确定要"
						+ MmochatUtil.wrapColor("洗去人物所有属性点和天赋点", Color.green)
						+ ",并重新分配么?";
			}
			CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
			msgbox.setContent(new Text(hint));
			msgbox.setLeftName("确定");
			msgbox.setRightName("取消");
			msgbox
					.addLeftTLV(new SendDataTLV(MmochatConstant
							.getClientModuleId(),
							MmochatMain.getModuleInstID(),
							MmochatConstant.MSGCODE_MMOCHAT_C_6_4, (int) me
									.getRoleId()));
			ShowWaitingMsgBoxTLV wait = new ShowWaitingMsgBoxTLV();
			wait.setShowCancel(false);
			msgbox.addLeftTLV(wait);
			return MmochatUtil.tlvResponse(req.getHallState(), msgbox);
		}
		case 游戏帮助手册: {
			String item[] = new String[] { "基本操作", "快捷键", "打怪指南", "角色系统",
					"宠物系统", "好友系统", "技能系统", "装备系统", "交易系统", "组队系统", "任务系统" };
			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinType(WinType.List);
			tlv.setTitle("游戏帮助手册");
			tlv.setRightName("返回");
			tlv.setLeftName("查看");
			tlv.setWinHeight(188);
			tlv.addRightTLV(new CloseWinTLV());
			for (int i = 0; i < item.length; i++) {
				tlv.addItemEvent(item[i], new ClearDataTLV(), new AddDataTLV(
						(int) i));
			}
			tlv
					.addLeftTLV(new SendDataTLV(MmochatConstant
							.getClientModuleId(),
							MmochatMain.getModuleInstID(),
							MmochatConstant.MSGCODE_MMOCHAT_C_9_6, (int) me
									.getRoleId()));
			tlv.addLeftTLV(new ShowWaitingMsgBoxTLV());
			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		case 认主系统: {
			if (checkStorePwd(me)) {
				return null;
			}
			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinType(WinType.List);
			tlv.setTitle("认主系统");
			tlv.setRightName("返回");
			tlv.setLeftName("确定");
			tlv.setWinHeight(188);
			tlv.addRightTLV(new CloseWinTLV());
			tlv.addItemEvent("装备法宝认主", new ClearDataTLV(), new AddDataTLV(
					(int) 1));
			tlv.addItemEvent("宠物认主", new ClearDataTLV(),
					new AddDataTLV((int) 2));
			tlv.addItemEvent("装备法宝解除认主", new ClearDataTLV(), new AddDataTLV(
					(int) 3));
			tlv.addItemEvent("宠物解除认主", new ClearDataTLV(), new AddDataTLV(
					(int) 4));
			tlv.addItemEvent("认主系统说明", new ClearDataTLV(), new AddDataTLV(
					(int) 5));

			tlv.addLeftTLV(new SendDataTLV(MmochatConstant.getClientModuleId(),
					MmochatMain.getModuleInstID(),
					MmochatConstant.MSGCODE_MMOCHAT_C_9_41, (int) me
							.getRoleId()));
			tlv.addLeftTLV(new ShowWaitingMsgBoxTLV());
			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		case 装备改造:
		case 属性抽取:
		case 装备合成:
		case 装备粉化:
		case 装备金化:
		case 制作套装:
		case 装备强化:
		case 套装明属性强化:
		case 套装暗属性强化:
		case 首饰升级:
		case 装备升级:
		case 装备绑定:
		case 装备解除绑定:
		case 转生装备进化:
		case 装备仙魔互转:
		case 新年礼物合成:
		case 龙年大礼包合成:
		case 元宵节礼包合成:
		case 武魂石鉴定:
		case 武魂石合成:
		case 武魂石升级:
		case 武魂石等级上限突破:
		case 武魂技能镶嵌:
		case 武魂技能分离: {
			// intro最好在65个字符内，超过65个后会以滚动形式显示
			if (checkStorePwd(me)) {
				return null;
			}
			int gridNum = 0;
			String intro = "";
			String detail = "";
			switch (type) {
			case 装备改造:
				gridNum = 6; // 装备+2块改造石+混沌石
				intro += "提交:1件装备、"
						+ MmochatUtil.getColorMoney(MmochatConstant
								.getModifyEquipPrice()) + "文\n";
				intro += MmochatUtil.wrapColor("可附加:2块(超级)改造石或2个改造灵珠、混沌石\n",
						Color.magenta);
				intro += MmochatUtil.wrapColor("说明:<菜单>-<改造说明>", Color.yellow);

				detail = "武器改造后可提升武器的伤害，防具改造后可提升防具的防御，首饰不能改造。\n";
				detail += MmochatUtil.wrapColor(
						"白装备可以直接改造，蓝金等其它颜色的装备需要额外提交2块(超级)改造石或2个改造灵珠\n",
						Color.yellow);
				detail += MmochatUtil
						.wrapColor(
								"改5的装备在改6时(或以下)失败不会消失，改6的装备在改7(或以上)失败时装备消失(提交混沌石可防止装备消失)。\n",
								Color.red);
				String greenInfo = "每件装备最高可改20，改造失败时装备改造等级降1级。"
						+ "改1到改20成功机率分别为";
				for (int v : MmochatEquipService.modifyRate) {
					greenInfo += v + "%、";
				}
				greenInfo += "提交2块超级改造石(商城有售)可额外增加改造成功率50%,提交2块改造灵珠(商城有售)改造成功率固定为50%，但改造失败不降改造等级。";
				detail += MmochatUtil.wrapColor(greenInfo, Color.green);
				break;
			case 属性抽取:
				gridNum = 2; // 装备+白水晶
				intro = "提交:一件装备、一块(超级)白水晶、"
						+ MmochatUtil.getColorMoney(MmochatConstant
								.getModifyEquipPrice()) + "文\n";
				intro += MmochatUtil.wrapColor("说明:<菜单>-<改造说明>", Color.yellow);
				detail = "属性抽取是制作套装的第一步。提交一件具有附加属性的装备和一块白水晶进行属性抽取，"
						+ "抽取成功后，装备中的一条附加属性就会转移到白水晶中。三块带属性的白水晶在<装备合成>"
						+ "功能里就能合出一件新的装备，白水晶中的属性会转移到新装备中。\n";
				detail += MmochatUtil.wrapColor(
						"超级白水晶(商城有售)抽取属性成功机率为100%,普通白水晶为"
								+ MmochatEquipService.separateEquipAttrRate
								+ "%,如果抽取失败，则白水晶消失，装备不消失。", Color.yellow);
				break;
			case 装备合成:
				gridNum = 4; // 装备+3白水晶
				intro = "提交:一件"
						+ MmochatUtil.wrapColor("未改造", Color.red)
						+ "白装备、三块黑水晶(白水晶吸属后变成黑水晶)、"
						+ MmochatUtil.getColorMoney(MmochatConstant
								.getModifyEquipPrice()) + "文\n";
				intro += MmochatUtil.wrapColor("说明:<菜单>-<改造说明>", Color.yellow);

				detail = "装备合成是制作套装的第二步。三块黑水晶(白水晶吸属后变成黑水晶)和一件未改造的白装备进行合成后，白装备变成蓝装备，"
						+ "黑水晶的属性转移到新生成的蓝装备中。装备合成不会失败。\n";
				detail += MmochatUtil.wrapColor(
						"黑水晶属性等级要与装备等级相同(如30级属性只能用于合成30级装备)，"
								+ "类型也要与装备类型一致(如从衣服中抽出的属性，只能用于合成衣服)，"
								+ "并且不能使用两块相同种类的属性黑水晶(如不能提交两块伤害属性的黑水晶)。",
						Color.yellow);
				break;
			case 装备粉化:
				gridNum = 2; // 蓝装备(粉装备)+粉水晶
				intro = "提交:一件蓝装备，或粉装备，或有粉属性的绿装备、一块粉水晶、"
						+ MmochatUtil.getColorMoney(MmochatConstant
								.getModifyEquipPrice()) + "文\n";
				intro += MmochatUtil.wrapColor("说明:<菜单>-<改造说明>", Color.yellow);

				detail = "装备粉化是制作套装的第三步。粉化过程能将一件蓝装备打造成粉装备。\n";
				detail += MmochatUtil.wrapColor(
						"蓝装备粉化成功后会增加一条粉属性，粉装备和绿装备粉化后会重新生成粉属性。" + "粉化过程成功率为"
								+ MmochatEquipService.pinkEquipAttrRate
								+ "%，如果粉化失败，则粉水晶消失，装备不消失。", Color.yellow);
				break;
			case 装备金化:
				gridNum = 3; // 粉装备+2块金水晶
				intro = "提交:一件粉装备、两块金水晶、"
						+ MmochatUtil.getColorMoney(MmochatConstant
								.getModifyEquipPrice()) + "文\n";
				intro += MmochatUtil.wrapColor("说明:<菜单>-<改造说明>", Color.yellow);

				detail = "装备金化是制作套装的第四步。只有金装备才能制作套装，所以粉装备需要经过金化，"
						+ "变成金装备。金化过程只改变装备品质。此操作不会失败。\n";
				break;
			case 制作套装:
				gridNum = 6; // 金装备(绿装备)+绿水晶+60个结晶
				intro = "提交:一件金装备或绿装备、一块绿水晶、60个结晶、"
						+ MmochatUtil.getColorMoney(MmochatConstant
								.getModifyEquipPrice()) + "文\n";
				intro += MmochatUtil.wrapColor("说明:<菜单>-<改造说明>", Color.yellow);

				detail = "只有金装备和绿装备才能制成套装。套装品质为绿装，是最高品质的装备。"
						+ "金装备制成套装后，会增加两条属性：套装明属性、套装暗属性。明属性直接有效，"
						+ "暗属性需要身上装备的武器、头盔、衣服、鞋子都是同等级同类型的套装时才有效"
						+ "(如都是30级野蛮套装)。绿装备经过制作后会重新生成套装明属性和暗属性。\n";
				detail += MmochatUtil.wrapColor(
						"套装分5类：野蛮、智慧、活力、坚韧、灵巧。套装类型与提交的结晶类型相同，"
								+ "如提交野蛮结晶，则制作出的套装为野蛮套装。"
								+ "结晶等级要与装备等级相符(如制作30级套装，则只能提交30级结晶)。"
								+ "不同类型的套装，其暗属性也不同。野蛮套装暗属性为物伤、"
								+ "智慧套装暗属性为法伤、活力套装暗属性为气血、坚韧套装暗属性为防御、"
								+ "灵巧套装暗属性为速度。\n", Color.cyan);
				detail += MmochatUtil.wrapColor("制作套装成功率为"
						+ MmochatEquipService.greenEquipAttrRate
						+ "%，制作失败时，绿水晶和结晶消失，装备不消失。", Color.yellow);
				break;
			case 装备强化:
				gridNum = 6; // 装备+强化水晶+白水晶
				intro = "提交:一件装备、一块强化水晶、一块黑水晶(白水晶吸属后变成黑水晶)、"
						+ MmochatUtil.getColorMoney(MmochatConstant
								.getModifyEquipPrice()) + "文\n";
				intro += MmochatUtil.wrapColor("说明:<菜单>-<改造说明>", Color.yellow);

				detail = "每个等级的装备，其附加属性数值都有一个最大值。当装备属性数值低于最大值时，"
						+ "这条属性就可以通过强化来提高属性数值，已经达到最大值的属性不能强化。首饰无法强化。\n";
				detail += MmochatUtil.wrapColor("属性强化需要提交一块黑水晶，黑水晶吸附的属性的数值"
						+ "与最终强化后的装备属性数值无关，黑水晶的属性仅仅只是决定了装备中哪条属性会被强化，"
						+ "(如黑水晶吸附的属性为伤害，则强化时会对装备中的一条伤害属性进行强化)"
						+ "强化后的数值由系统随机生成，如果新生成的数值低于原属性数值，则强化失败，"
						+ "并且原属性数值保持不变，不会降低。强化后黑水晶不会消失。\n", Color.yellow);
				detail += MmochatUtil.wrapColor(
						"装备中的附加属性和粉属性可以强化，套装属性与改造属性无法强化。"
								+ "如果装备中有两条属性与黑水晶属性种类相同，则强化数值较低的一条。",
						Color.magenta);
				break;
			case 套装明属性强化:
				gridNum = 6; // 装备+强化水晶
				intro = "提交:一件绿装备、两块套装明属性强化水晶、"
						+ MmochatUtil.getColorMoney(MmochatConstant
								.getModifyEquipPrice()) + "文\n";
				intro += MmochatUtil.wrapColor("说明:<菜单>-<改造说明>", Color.yellow);

				detail = "套装明属性强化，可以将套装中的明属性数值进行强化，不改变属性类型。强化后的数值由系统随机生成，"
						+ "如果新生成的数值低于原属性数值，则原属性数值保持不变，不会降低，否则属性数值提升。";
				break;
			case 套装暗属性强化:
				gridNum = 6; // 装备+强化水晶
				intro = "提交:一件绿装备、一块套装暗属性强化水晶、"
						+ MmochatUtil.getColorMoney(MmochatConstant
								.getModifyEquipPrice()) + "文\n";
				intro += MmochatUtil.wrapColor("说明:<菜单>-<改造说明>", Color.yellow);

				detail = "套装暗属性强化，可以将套装中的暗属性数值进行强化，不改变属性类型。强化后的数值由系统随机生成，"
						+ "如果新生成的数值低于原属性数值，则原属性数值保持不变，不会降低，否则属性数值提升。";
				break;
			case 首饰升级:
				gridNum = 3; // 首饰+2块女娲石
				intro = "提交:一件首饰(玉佩、手镯、挂坠)、两块女娲石、"
						+ MmochatUtil.getColorMoney(MmochatConstant
								.getModifyEquipPrice()) + "文\n";
				intro += MmochatUtil.wrapColor("说明:<菜单>-<改造说明>", Color.yellow);

				detail = "首饰是装备中最稀有的品种，首饰和女娲石在一些活动中击杀活动怪物有机率获得。"
						+ "天然掉落的首饰都是0级的首饰，并且没有附加属性。首饰可以升级，"
						+ "每次升级，装备等级会提升20级，并且增加一条随机属性。\n";
				detail += MmochatUtil.wrapColor(
						"升级首饰不会失败。首饰无法进行改造、强化、属性抽取、粉化、金化等操作。"
								+ "首饰的属性一旦生成，就无法改变。", Color.yellow);
				break;
			case 装备升级:
				gridNum = 6; // 装备+2块升级石

				intro = "提交:一件装备、两块升级石、"
						+ MmochatUtil.getColorMoney(MmochatConstant
								.getModifyEquipPrice()) + "文\n";
				intro += MmochatUtil.wrapColor("说明:<菜单>-<改造说明>", Color.yellow);

				detail = "低级装备可以升级为高级装备，升级后改造等级、附加属性、粉属性、"
						+ "套装属性都可以保留下来。装备升到整10级时，如30级装备升级到40级，"
						+ "装备的基础属性也会提升到40级的数值，改造属性的数值也会相应提升到40级的数值，"
						+ "随机属性、粉属性、套装属性的数值会按比例提升到40级的数值"
						+ "(如原来属性数值是30级装备数值的最大值，升级后变为40级装备数值的最大值)。\n";
				detail += MmochatUtil.wrapColor(
						"每次升级，装备等级提升1级，但装备等级未提升到整10级前，装备属性不会变化"
								+ "(如装备从30级提升到31级，装备属性不变，"
								+ "只有提升到40级时装备才会提升到40级属性水平)。\n", Color.yellow);
				detail += MmochatUtil
						.wrapColor(
								"装备升级有一定成功机率，提升1级时成功机率为100%，提升2级时为98%，往后依次成功机率为"
										+ "95%，90%，85%，80%，75%，70%，65%，60%，提升5级前失败后等级不会回退，"
										+ "提升6级到10级期间，失败时装备等级降1级。\n",
								Color.magenta);
				break;
			case 装备绑定:
				gridNum = 1; // 装备

				intro = "提交:一件装备、"
						+ MmochatUtil.getColorMoney(MmochatConstant
								.getModifyEquipPrice()) + "文\n";
				intro += MmochatUtil.wrapColor("说明:绑定后无法遗弃", Color.yellow);

				detail = "绑定的装备无法遗弃。但可以正常交易。\n";
				break;
			case 装备解除绑定:
				gridNum = 1; // 装备

				intro = "提交:一件装备、"
						+ MmochatUtil.getColorMoney(MmochatConstant
								.getModifyEquipPrice()) + "文\n";
				intro += MmochatUtil.wrapColor("说明:解除绑定。", Color.yellow);

				detail = "绑定的装备需要解绑后才能进行遗弃。\n";
				break;
			case 转生装备进化: {
				gridNum = 6; // 装备

				intro = "提交:一件120级绿装备、4块升级石、8块进化石、"
						+ MmochatUtil.getColorMoney(MmochatConstant
								.getModifyEquipPrice()) + "文\n";
				intro += MmochatUtil.wrapColor("说明:<菜单>-<改造说明>", Color.yellow);

				detail = "人物转身后，可以将"
						+ MmochatUtil.wrapColor("120级绿装备", Color.green)
						+ "进化到相应的层次，如1转角色，可以将绿装备进化到<1转装备>，"
						+ "2转角色，最多可以将绿装备进化到<2转装备>。进化一转装备时，需要提交一转进化石，一转装备"
						+ "进化到二转装备时，需要提交二转进化石。进化成功率100%。\n";
				detail += MmochatUtil.wrapColor(
						"人物如果为仙道，那么装备进化后也将变为仙道装备，仙道装备进化改造属性为法伤；"
								+ "人物如果为魔道，那么装备进化后也将变为魔道装备，魔道装备进化改造属性为物伤。"
								+ "仙道装备只能被仙道人物使用，魔道装备只能被魔道人物使用。"
								+ "通过<装备仙魔互转>可以变更装备的仙魔属性。", Color.yellow);
				break;
			}
			case 装备仙魔互转: {
				gridNum = 6; // 装备

				intro = "提交:一件转生装备、1块仙魔转换石、4块(超级)白水晶、"
						+ MmochatUtil.getColorMoney(MmochatConstant
								.getModifyEquipPrice()) + "文\n";
				intro += MmochatUtil.wrapColor("说明:<菜单>-<改造说明>", Color.yellow);

				detail = "通过仙魔互转，仙道装备转换成魔道装备，魔道装备转换成仙道装备。\n";
				break;
			}
			case 新年礼物合成: {
				gridNum = 6; // 装备

				intro = "提交:新年快乐o新、新年快乐o年、新年快乐o快、新年快乐o乐，每样各1份、"
						+ MmochatUtil.getColorMoney(MmochatConstant
								.getModifyEquipPrice()) + "文\n";
				intro += MmochatUtil.wrapColor("说明:<菜单>-<改造说明>", Color.yellow);

				detail = "新年快乐o新、新年快乐o年、新年快乐o快、新年快乐o乐，每样提交1份，"
						+ "可以合成<新年大礼包>。\n";
				break;
			}
			case 龙年大礼包合成: {
				gridNum = 6; // 装备

				intro = "提交:龙年大吉o龙、龙年大吉o年、龙年大吉o大、龙年大吉o吉，每样各1份、"
						+ MmochatUtil.getColorMoney(MmochatConstant
								.getModifyEquipPrice()) + "文\n";
				intro += MmochatUtil.wrapColor("说明:<菜单>-<改造说明>", Color.yellow);

				detail = "龙年大吉o龙、龙年大吉o年、龙年大吉o大、龙年大吉o吉，每样提交1份，"
						+ "可以合成<龙年大礼包>。\n";
				break;
			}
			case 元宵节礼包合成: {
				gridNum = 6; // 装备

				intro = "提交:庆元宵o庆、庆元宵o元、庆元宵o宵，每样各1份、"
						+ MmochatUtil.getColorMoney(MmochatConstant
								.getModifyEquipPrice()) + "文\n";
				intro += MmochatUtil.wrapColor("说明:<菜单>-<改造说明>", Color.yellow);

				detail = "庆元宵o庆、庆元宵o元、庆元宵o宵，每样提交1份，" + "可以合成<元宵节礼包>。\n";
				break;
			}
			case 武魂石鉴定: {
				gridNum = 1;

				intro = "提交:1块武魂石(未鉴定)、"
						+ MmochatUtil
								.getColorMoney(MmochatConstant.checkPkStonePrice)
						+ "文\n";
				intro += MmochatUtil.wrapColor("说明:<菜单>-<改造说明>", Color.yellow);

				detail = "武魂石(未鉴定)，通过鉴定后，可以随机生成一条技能属性，技能石等级初始1级，"
						+ "有小机率直接生成较高等级技能石。\n";
				break;
			}
			case 武魂石合成: {
				gridNum = 4;

				intro = "提交:4块武魂石(已鉴定)、"
						+ MmochatUtil
								.getColorMoney(MmochatConstant.checkPkStonePrice)
						+ "文\n";
				intro += MmochatUtil.wrapColor(
						"说明:合成1个新的武魂石(属性随机)，详见<菜单>-<改造说明>", Color.yellow);

				detail = "4块已鉴定过的武魂石，可以重新合成一个新的武魂石，随机生成一条技能属性，技能石等级初始1级，"
						+ "有小机率直接生成较高等级技能石。建议将不需要的武魂石进行合成。\n";
				break;
			}
			case 武魂石升级: {
				gridNum = 6;

				intro = "提交:1块武魂石、若干武魂石灵气丹或武魂石灵气池、"
						+ MmochatUtil.getColorMoney(MmochatConstant
								.getModifyEquipPrice()) + "文\n";
				intro += MmochatUtil.wrapColor("说明:<菜单>-<改造说明>", Color.yellow);

				detail = "武魂石(已鉴定)，可吸收提交的武魂石灵气丹，或武魂石灵气池中的灵气，"
						+ "当武魂石灵气达到升级灵气时，将自动升级，升级后武魂石附带技能的数值提升。"
						+ "武魂石等级达到等级上限时，不再升级，但仍可吸收灵气。等级上限得到突破后，可继续升级。\n";
				break;
			}
			case 武魂石等级上限突破: {
				gridNum = 6;
				intro = "提交:1块武魂石、若干武魂突破石、"
						+ MmochatUtil.getColorMoney(MmochatConstant
								.getModifyEquipPrice()) + "文\n";
				intro += MmochatUtil.wrapColor("说明:<菜单>-<改造说明>", Color.yellow);

				detail = "武魂石等级上限未达到" + MmochatConstant.pkStoneMaxLevel
						+ "时，可使用武魂突破石，突破等级上限。等级突破100%成功，但"
						+ "当前等级越高，所需武魂突破石越多。从"
						+ MmochatConstant.pkStoneInitLevelLimit + "级到"
						+ (MmochatConstant.pkStoneMaxLevel - 1)
						+ "级，突破等级时所需突破石数量依次为:";
				for (int i = MmochatConstant.pkStoneInitLevelLimit; i < MmochatConstant.pkStoneMaxLevel; i++) {
					detail += MmochatEquipService.pkStoneUplevelNum[i] + "块、";
				}
				break;
			}
			case 武魂技能镶嵌: {
				gridNum = 6;
				intro = "提交:1个武魂、若干武魂石(基础类型相同)、"
						+ MmochatUtil.getColorMoney(MmochatConstant
								.getModifyEquipPrice()) + "文\n";
				intro += MmochatUtil.wrapColor("说明:<菜单>-<改造说明>", Color.yellow);

				detail = "可将武魂石上的技能镶嵌到武魂上，使武魂获得此技能效果，要求所有武魂石的基础类型"
						+ "全部相同。镶嵌后武魂的基础类型数值，与镶嵌的武魂石中基础类型最小的数值一致。"
						+ "技能石也可以重新分离出来。";
				break;
			}
			case 武魂技能分离: {
				gridNum = 1;
				intro = "提交:1个武魂、"
						+ MmochatUtil
								.getColorMoney(MmochatConstant.seperatePkStonePrice)
						+ "文\n";
				intro += MmochatUtil.wrapColor("说明:<菜单>-<改造说明>", Color.yellow);

				detail = "可将武魂石上的技能分离出来，分离出的技能以武魂石形式存放。分离出的武魂石可重新合成到武魂上。";
				break;
			}
			default:
				break;
			}
			Mmochat_14_11S pack = new Mmochat_14_11S();
			pack.setType(type);
			pack.setTitle(type.toString());
			pack.setIntro(intro);
			pack.setDetail(detail);
			pack.setGridNum(gridNum);
			return pack;
		}
		case 武魂系统介绍: {
			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinType(WinType.List);
			tlv.setLeftName("查看");
			tlv.setRightName("返回");
			tlv.setTitle(type.toString());
			tlv.setWinHeight(188);
			tlv.addRightTLV(new CloseWinTLV());
			tlv.addItemEvent("什么是武魂", new ClearDataTLV(), new AddDataTLV(
					(int) 1));
			tlv.addItemEvent("武魂品质", new ClearDataTLV(),
					new AddDataTLV((int) 3));
			tlv.addItemEvent("如何镶嵌武魂技能", new ClearDataTLV(), new AddDataTLV(
					(int) 4));
			tlv.addItemEvent("武魂石技能", new ClearDataTLV(), new AddDataTLV(
					(int) 5));
			tlv.addItemEvent("武魂石如何升级", new ClearDataTLV(), new AddDataTLV(
					(int) 6));
			tlv.addItemEvent("武魂石等级上限", new ClearDataTLV(), new AddDataTLV(
					(int) 7));
			tlv.addItemEvent("武魂技能分离", new ClearDataTLV(), new AddDataTLV(
					(int) 8));
			tlv.addLeftTLV(new SendDataTLV(MmochatConstant.getClientModuleId(),
					MmochatMain.getModuleInstID(),
					MmochatConstant.MSGCODE_MMOCHAT_C_9_63, (int) me
							.getRoleId()));
			tlv.addLeftTLV(new ShowWaitingMsgBoxTLV());
			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		case 存放物品: {
			Mmochat_12_15S pack = new Mmochat_12_15S();
			pack.setHallState(req.getHallState());
			return pack;
		}
		case 取回物品: {
			if (checkStorePwd(me)) {
				return null;
			}
			// 整理仓库
			MmochatStoreService.orderStorage(me);

			List<MmochatPackageGrid> grids = new ArrayList<MmochatPackageGrid>();
			for (MmochatPackageGrid grid : me.getMyStorage().values()) {
				if (grid.getObject() != null) {
					grids.add(grid);
				}
			}
			SendBigPackUtil.sendBigPack_12_18S(me, grids);
			return null;
		}
		case 存放宠物: {
			Mmochat_12_23S pack = new Mmochat_12_23S();
			pack.setHallState(req.getHallState());
			return pack;
		}
		case 取回宠物: {
			if (checkStorePwd(me)) {
				return null;
			}
			if (me.getStoredPets().size() == 0) {
				return MmochatUtil.msgbox(req.getHallState(), "您没有寄存的宠物!");
			}
			CreateTlvWin tlv = MmochatStoreService.getStoredPetList(me);
			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		case 押送镖银: {
			int minTeamNum = 3;
			int minLevel = 30;
			Date now = new Date();
			if (now.getDay() != 6) {
				return MmochatUtil.msgbox(req.getHallState(),
						"押送镖银活动在每周六21:00-22:00举办!");
			}
			if (now.getHours() != 21) {
				return MmochatUtil.msgbox(req.getHallState(),
						"押送镖银活动在21:00-22:00举办，现在还不是活动时间。");
			}

			List<MmochatPlayer> teamers = new ArrayList<MmochatPlayer>();
			if (me.isInTeam()) {
				MmochatTeam team = MmochatTeamService.teams.get(me.getTeamId());
				if (team == null) {
					me.leaveTeam();
					teamers.add(me);
				} else {
					for (Integer roleId : team.getMemberId().values()) {
						MmochatPlayer member = MmochatMainService.players
								.get(roleId);
						if (member != null) {
							teamers.add(member);
						}
					}
				}
			} else {
				teamers.add(me);
			}
			if (teamers.size() < minTeamNum) {
				return MmochatUtil.msgbox(req.getHallState(), "至少" + minTeamNum
						+ "人才能参加活动!");
			}

			now.setHours(0);
			now.setMinutes(0);
			// 检测参加次数，每天最多20次；参加等级，最少30级
			for (MmochatPlayer member : teamers) {
				if (member.getLevel() < minLevel) {
					return MmochatUtil.msgbox(req.getHallState(), MmochatUtil
							.wrapColor(member.getName(), Color.green)
							+ "的等级不足" + minLevel + "级，不能参加此活动!");
				}
				MmochatDailyActivity activity = member.getDailyActivities()
						.get(MmochatDailyActivityType.押送镖银);

				if (activity == null) {
					// 第一次参加此活动
					activity = new MmochatDailyActivity();
					activity.setType(MmochatDailyActivityType.押送镖银);
					member.addDailyActivity(activity);
				}

				if (activity.getLastTime() < now.getTime()) {
					activity.setDailyTimes(0);
				}
				if (activity.getDailyTimes() >= activity.getType()
						.getMaxDailyTimes()) {
					// 今天已经完成次数达到上限，不能再参加
					return MmochatUtil.msgbox(req.getHallState(), "今天"
							+ MmochatUtil.wrapColor(member.getName(),
									Color.green) + "已经押送"
							+ activity.getType().getMaxDailyTimes()
							+ "趟镖银了，不能继续参加了。");
				}
			}

			// 领取任务
			MmochatTaskType[] subTaskTypes = new MmochatTaskType[] {
					MmochatTaskType.押送镖银之消灭饕餮, MmochatTaskType.押送镖银之消灭巫妖,
					MmochatTaskType.押送镖银之消灭蟹将, MmochatTaskType.押送镖银之消灭彼岸花 };
			for (MmochatPlayer member : teamers) {
				// 增加参加次数
				MmochatDailyActivity activity = member.getDailyActivities()
						.get(MmochatDailyActivityType.押送镖银);
				if (activity != null) {
					activity.addDailyTimes(1);
					activity.setLastTime(System.currentTimeMillis());
				}

				int curTaskTurn = 1;
				// 删除旧的任务
				for (MmochatTaskType taskType : subTaskTypes) {
					MmochatTask myTask = member.getTaskByType(taskType);
					if (myTask != null) {
						if (!myTask.isInvalid()) {
							// 未过期的任务，可以按上次的轮次
							curTaskTurn = myTask.getTaskTurn();// 任务未完成，仍然使用当前的任务轮次
						}
						member.getTasks().remove(myTask.getTaskId());
						MmochatTaskService.YBTasks.remove(myTask.getTaskId());
						MmochatNpc finishNpc = MmochatNpcService
								.getNpcById(myTask.getFinish_npcId());
						if (finishNpc != null) {
							finishNpc.getTasks().remove(myTask.getTaskId());
						}
						// 下发删除任务
						Mmochat_4_12S taskPack = new Mmochat_4_12S();
						taskPack.setTaskId(myTask.getTaskId());
						MmochatUtil.sendCommonPack(member, taskPack);
					}
				}

				MmochatTask myTask = member.getTaskByType(MmochatTaskType.押送镖银);
				if (myTask != null
						&& myTask.getTaskState() != MmochatTaskStateType.已完成) {
					if (!myTask.isInvalid()) {
						// 未过期的任务，可以按上次的轮次
						curTaskTurn = myTask.getTaskTurn();// 任务未完成，仍然使用当前的任务轮次
					}
					member.getTasks().remove(myTask.getTaskId());
					MmochatTaskService.YBTasks.remove(myTask.getTaskId());
					MmochatNpc finishNpc = MmochatNpcService.getNpcById(myTask
							.getFinish_npcId());
					if (finishNpc != null) {
						finishNpc.getTasks().remove(myTask.getTaskId());
					}
					// 下发删除任务
					Mmochat_4_12S taskPack = new Mmochat_4_12S();
					taskPack.setTaskId(myTask.getTaskId());
					MmochatUtil.sendCommonPack(member, taskPack);
				} else if (myTask != null
						&& myTask.getTaskState() == MmochatTaskStateType.已完成) {
					if (!myTask.isInvalid()) {
						// 未过期的任务，可以按上次的轮次
						myTask.addTaskTurn();// 任务已完成，任务轮次增加
						curTaskTurn = myTask.getTaskTurn();
					}
					member.getTasks().remove(myTask.getTaskId());
					MmochatTaskService.YBTasks.remove(myTask.getTaskId());
					MmochatNpc finishNpc = MmochatNpcService.getNpcById(myTask
							.getFinish_npcId());
					if (finishNpc != null) {
						finishNpc.getTasks().remove(myTask.getTaskId());
					}
					// 下发删除任务
					Mmochat_4_12S taskPack = new Mmochat_4_12S();
					taskPack.setTaskId(myTask.getTaskId());
					MmochatUtil.sendCommonPack(member, taskPack);
				}

				// 创建新的任务
				int monsterNum = 3 + teamers.size();
				int finish_npcId;
				MmochatNpc finishNpc;

				// 最后一步对话任务
				String task5Detail = "第" + curTaskTurn + "轮:成功击杀劫镖匪徒，保住镖银。现在前往"
						+ MmochatUtil.wrapColor("开封(852,842)", Color.magenta)
						+ "，将镖银交给"
						+ MmochatUtil.wrapColor("大内总管", Color.yellow)
						+ "领取赏金吧!";
				MmochatTempTask task5 = new MmochatTempTask(true);
				task5.setTaskType(MmochatTaskType.押送镖银);
				task5.setTaskTurn(curTaskTurn);
				task5.setTaskName(task5.getTaskType().toString());
				task5.setTaskState(MmochatTaskStateType.已接);
				task5.setFinish_npcId(18);
				task5.setTaskDetail(task5Detail);
				task5.setFinish_award_money(curTaskTurn
						* MmochatConstant.turnMoneyParamForYB
						+ MmochatConstant.baseMoneyForYB);

				task5.setTaskLife(MmochatConstant.MS_PER_HOUR);
				MmochatTaskService.YBTasks.put(task5.getTaskId(), task5);

				// 第四个怪
				// finish_npcId = 85;
				// Integer nextAccept_task4Id = task5.getTaskId();
				// String task4Detail = "第" + curTaskTurn +
				// "轮:替官府押送镖银到开封，交给大内总管。"
				// + "接到密报死海彼岸花将来劫镖，特先发制人，前往"
				// + MmochatUtil.wrapColor("死海(205,86)", Color.magenta)
				// + "击杀" + MmochatUtil.wrapColor("彼岸花", Color.yellow)
				// + "!";
				// MmochatTask task4 = createYBTask(me,
				// MmochatTaskType.押送镖银之消灭彼岸花, curTaskTurn, monsterNum,
				// nextAccept_task4Id, finish_npcId, task4Detail,
				// MmochatRoleBmpType.小草, "劫镖彼岸花", 0, 0, 0, 50);
				// MmochatTaskService.YBTasks.put(task4.getTaskId(), task4);
				// finishNpc = MmochatNpcService.getNpcById(finish_npcId);
				// if (finishNpc != null) {
				// finishNpc.addTask(task4);
				// }

				// 第三个怪
				finish_npcId = 28;
				Integer nextAccept_task3Id = task5.getTaskId();
				String task3Detail = "第" + curTaskTurn + "轮:替官府押送镖银到开封，交给大内总管。"
						+ "接到密报东海蟹将将来劫镖，特先发制人，前往"
						+ MmochatUtil.wrapColor("东海(289,119)", Color.magenta)
						+ "击杀" + MmochatUtil.wrapColor("蟹将", Color.yellow)
						+ "!";
				MmochatTask task3 = createYBTask(me, MmochatTaskType.押送镖银之消灭蟹将,
						curTaskTurn, monsterNum, nextAccept_task3Id,
						finish_npcId, task3Detail, MmochatRoleBmpType.壮男,
						"劫镖蟹将", 0, 0, 50, 0);
				MmochatTaskService.YBTasks.put(task3.getTaskId(), task3);
				finishNpc = MmochatNpcService.getNpcById(finish_npcId);
				if (finishNpc != null) {
					finishNpc.addTask(task3);
				}

				// 第二个怪
				finish_npcId = 44;
				Integer nextAccept_task2Id = task3.getTaskId();
				String task2Detail = "第" + curTaskTurn + "轮:替官府押送镖银到开封，交给大内总管。"
						+ "接到密报沼泽巫妖将来劫镖，特先发制人，前往"
						+ MmochatUtil.wrapColor("沼泽(53,118)", Color.magenta)
						+ "击杀" + MmochatUtil.wrapColor("巫妖", Color.yellow)
						+ "!";
				MmochatTask task2 = createYBTask(me, MmochatTaskType.押送镖银之消灭巫妖,
						curTaskTurn, monsterNum, nextAccept_task2Id,
						finish_npcId, task2Detail, MmochatRoleBmpType.美女1,
						"劫镖巫妖", 0, 50, 0, 0);
				MmochatTaskService.YBTasks.put(task2.getTaskId(), task2);
				finishNpc = MmochatNpcService.getNpcById(finish_npcId);
				if (finishNpc != null) {
					finishNpc.addTask(task2);
				}

				// 第一个怪
				finish_npcId = 46;
				Integer nextAccept_task1Id = task2.getTaskId();
				String task1Detail = "第" + curTaskTurn + "轮:替官府押送镖银到开封，交给大内总管。"
						+ "接到密报西海饕餮将来劫镖，特先发制人，前往"
						+ MmochatUtil.wrapColor("西海(421,334)", Color.magenta)
						+ "击杀" + MmochatUtil.wrapColor("饕餮", Color.yellow)
						+ "!";
				MmochatTask task1 = createYBTask(me, MmochatTaskType.押送镖银之消灭饕餮,
						curTaskTurn, monsterNum, nextAccept_task1Id,
						finish_npcId, task1Detail, MmochatRoleBmpType.动物,
						"劫镖饕餮", 50, 0, 0, 0);
				MmochatTaskService.YBTasks.put(task1.getTaskId(), task1);
				finishNpc = MmochatNpcService.getNpcById(finish_npcId);
				if (finishNpc != null) {
					finishNpc.addTask(task1);
				}

				member.addTask(task1);
				// 下发增加任务
				Mmochat_4_11S pack = new Mmochat_4_11S();
				pack.setActionType(0);
				pack.setMe(member);
				pack.setTask(task1);
				MmochatUtil.sendCommonPack(member, pack);

				if (MmochatTeamService.getTeamState(member) == MmochatTeamStateType.队员) {
					MmochatUtil.sendCommonMsgbox(member, task1Detail);
				} else {
					CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
					msgbox.setContent(new Text(task1Detail));
					msgbox.setLeftName("确定");
					msgbox.addLeftTLV(new CallLocalFuncTlv(
							MmochatConstant.funcode_worldPathFunc, finishNpc
									.getMapId(), finishNpc.getX(), finishNpc
									.getY()));

					CtrlTLVStructureRequest tracePack = MmochatUtil
							.tlvResponseWithoutHallState(msgbox);
					MmochatUtil.sendCommonPack(member, tracePack);
				}
			}
			break;
		}
		case 押镖说明: {
			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinType(WinType.Text);
			tlv.setRightName("返回");
			tlv.setTitle("押镖说明");
			tlv.setWinHeight(188);
			tlv.addRightTLV(new CloseWinTLV());
			String content = "";
			content += MmochatUtil.wrapColor("[活动时间]\n", Color.green);
			content += "每周六21:00-22:00\n\n";
			content += MmochatUtil.wrapColor("[活动规则]\n", Color.green);
			content += "至少3人组队，任务每10个一轮。接受任务后需先后前往击杀"
					+ "西海(饕餮)、沼泽(巫妖)、东海(蟹将)这三路劫镖匪徒，这3路怪分别对三个门派的法术抗50%。"
					+ "最后到开封向大内总管交差及领取赏金。任务领取后不能飞回门派、"
					+ "不能使用(超级)八卦令、不能使用传送符、不能通过NPC传送。\n\n";
			content += MmochatUtil.wrapColor("[活动奖励]\n", Color.green);
			content += "金钱奖励随着轮次增高而增加，第10轮有机率获得10倍奖励。第1轮"
					+ (MmochatConstant.turnMoneyParamForYB + MmochatConstant.baseMoneyForYB)
					+ "文钱，以后每轮递增" + MmochatConstant.turnMoneyParamForYB + "文钱!";

			tlv.setContent(new Text(content));
			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		case 交还镖银: {
			// 判断队伍中所有人，如果有任务5,则完成任务，并且给钱。
			// 第10轮完成时有小机率获得10倍金钱奖励，并公告天下
			List<MmochatPlayer> teamers = new ArrayList<MmochatPlayer>();
			if (me.isInTeam()) {
				MmochatTeam team = MmochatTeamService.teams.get(me.getTeamId());
				if (team == null) {
					me.leaveTeam();
					teamers.add(me);
				} else {
					for (Integer roleId : team.getMemberId().values()) {
						MmochatPlayer member = MmochatMainService.players
								.get(roleId);
						if (member != null) {
							teamers.add(member);
						}
					}
				}
			} else {
				teamers.add(me);
			}
			for (MmochatPlayer member : teamers) {
				try {
					MmochatTask myTask = member
							.getTaskByType(MmochatTaskType.押送镖银);
					if (myTask != null
							&& myTask.getTaskState() != MmochatTaskStateType.已完成) {
						// 完成任务
						myTask.setTaskState(MmochatTaskStateType.已完成);

						// 下发删除任务
						Mmochat_4_12S taskPack = new Mmochat_4_12S();
						taskPack.setTaskId(myTask.getTaskId());
						MmochatUtil.sendCommonPack(member, taskPack);

						// 发送奖励
						boolean bigAward = false;
						if (myTask.getTaskTurn() == 10) {
							if (MmochatUtil.isInPercent(0.2)) {
								bigAward = true;
							}
						}
						int moneyAward = myTask.getFinish_award_money();
						if (bigAward) {
							moneyAward = moneyAward * 10;
						}
						member.addAndUpdateSmall_money(moneyAward);
						try {
							MmochatStatisticsService.addSmallMoneyEarn(
									MmochatSmallMoneyEarnType.押送镖银, moneyAward);
							Integer oldMoney = YBMap.get(member.getRoleId());
							if (oldMoney == null) {
								oldMoney = 0;
							}
							oldMoney += moneyAward;
							YBMap.put(member.getRoleId(), oldMoney);
						} catch (Exception e) {
							e.printStackTrace();
						}

						String msg = "您完成第"
								+ myTask.getTaskTurn()
								+ "轮押送镖银任务，获得"
								+ MmochatUtil.wrapColor(moneyAward,
										Color.yellow) + "文钱奖励!";
						MmochatUtil.sendCommonMsgbox(member, msg);
						if (bigAward) {
							String sysMsg = "好人好报啊!"
									+ MmochatUtil.wrapColor(member.getName(),
											Color.green)
									+ "在完成第10轮押送镖银任务时，意外得获得了"
									+ MmochatUtil.wrapColor("10倍金钱奖励",
											Color.magenta) + "!";
							MmochatChatService.sendSystemMsg(sysMsg);
						}
					} else {
						MmochatUtil.sendCommonMsgbox(member, "您现在不能交还镖银。");
					}
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			break;
		}
		case 除暴安良:
		case 斩妖除魔:
		case 修仙之路: {
			int minLevel = 1, maxLevel = MmochatConstant.maxLevel;
			int minTeamerNum = 1;
			Integer[] maps = null;
			String[] bossName = null;
			String[] monsterName = null;
			String[] bossBmp = null;
			String[] monsterBmp = null;
			List<String> defalutMsg = new ArrayList<String>();
			int equipLevel = 0;
			int expectTeamNum = 2;
			double bossPhysicalAttack = 0, bossPhysicalAttackPercent = 0, bossMagicAttack = 0, bossMagicAttackPercent = 0;
			double monsterPhysicalAttack = 0, monsterPhysicalAttackPercent = 0, monsterMagicAttack = 0, monsterMagicAttackPercent = 0;
			int bossSuperPhysicalAttack = 0, bossSuperSpritAttack = 0;
			int monsterSuperPhysicalAttack = 0, monsterSuperSpritAttack = 0;
			int bossMagicAttackNum = 3;
			MmochatTaskType taskType = MmochatTaskType.其它;
			if (type == MmochatNpcItemType.除暴安良) {
				// 除暴安良NPC在mapId=0
				minLevel = 20;
				maxLevel = 39;
				minTeamerNum = 1;
				taskType = MmochatTaskType.除暴安良;
				if (me.getLevel() < 30) {
					maps = new Integer[] { 11, 10, 2, 23, 1 };
				} else {
					maps = new Integer[] { 10, 23, 1, 20, 3 };
				}
				bossName = new String[] { "范统", "韦君智", "梅人品", "梅有钱", "杜子腾",
						"枚良心", "布是人", "贾好人", "懒旱", "若智", "大笨", "阿呆" };
				bossBmp = new String[] { "官", "壮男", "官", "壮男1", "乞丐", "风流才子",
						"动物1", "官", "乞丐", "和尚", "儿童", "儿童" };
				monsterName = new String[] { "小罗罗", "韦人", "贼兵", "小钱", "食人草",
						"旺财", "鬼", "坏人", "食人草", "小沙弥", "呆鸟", "傻鸟" };
				monsterBmp = new String[] { "士兵", "壮男1", "士兵", "壮男", "小草",
						"动物", "鬼", "士兵", "小草", "老头", "凤凰", "凤凰" };

				defalutMsg.add("看什么看,没见过这么帅的强盗么?!");

				expectTeamNum = 1;
				bossPhysicalAttack = 0.25;
				bossMagicAttack = 0.2;
				bossPhysicalAttackPercent = 0.75;
				bossMagicAttackPercent = 0.25;
				bossMagicAttackNum = 3;
				bossSuperPhysicalAttack = 10;
				bossSuperSpritAttack = 10;
				monsterPhysicalAttack = 0.15;
				monsterMagicAttack = 0.12;
				monsterPhysicalAttackPercent = 1;
				monsterMagicAttackPercent = 0;
				monsterSuperPhysicalAttack = 5;
				monsterSuperSpritAttack = 5;
				equipLevel = 2;
			} else if (type == MmochatNpcItemType.斩妖除魔) {
				// 斩妖除魔NPC在mapId=4
				minLevel = 40;
				maxLevel = 79;
				minTeamerNum = 1;
				taskType = MmochatTaskType.斩妖除魔;
				if (me.getLevel() < 50) {
					maps = new Integer[] { 16, 3, 19, 20 };
				} else if (me.getLevel() < 60) {
					maps = new Integer[] { 16, 19, 20 };
				} else if (me.getLevel() < 70) {
					maps = new Integer[] { 13, 14, 19, 20 };
				} else {
					maps = new Integer[] { 13, 8, 9 };
				}
				bossName = new String[] { "伏地魔", "炎魔", "梦魔", "赛太岁", "蛟魔王",
						"妖后", "古柏老", "病魔", "黄风怪", "黄袍怪", "独角王", "多目怪", "玄鹤老" };
				bossBmp = new String[] { "动物1", "动物1", "动物1", "动物1", "龙宫", "鬼",
						"和尚", "动物1", "动物1", "动物1", "动物", "怪物", "老头" };
				monsterName = new String[] { "兽王", "炎兽", "梦魇", "太岁", "蛟龙",
						"人妖", "老头", "病魇", "旋风小子", "虎头兽", "红凤", "单眼怪", "侍女" };
				monsterBmp = new String[] { "动物", "动物", "鬼", "和尚", "怪物", "怪物",
						"老头", "怪物", "怪物", "动物", "凤凰", "教徒", "鬼" };
				defalutMsg.add("别点我,我对你没兴趣?!");

				expectTeamNum = 2;
				bossPhysicalAttack = 0.4;
				bossMagicAttack = 0.3;
				bossPhysicalAttackPercent = 0.75;
				bossMagicAttackPercent = 0.25;
				bossMagicAttackNum = 4;
				bossSuperPhysicalAttack = 10;
				bossSuperSpritAttack = 10;
				monsterPhysicalAttack = 0.2;
				monsterMagicAttack = 0.15;
				monsterPhysicalAttackPercent = 1;
				monsterMagicAttackPercent = 0;
				monsterSuperPhysicalAttack = 5;
				monsterSuperSpritAttack = 5;
				equipLevel = 4;
			} else if (type == MmochatNpcItemType.修仙之路) {
				// 修仙之路NPC在mapId=5
				minLevel = 80;
				maxLevel = MmochatConstant.maxLevel;
				minTeamerNum = 1;
				taskType = MmochatTaskType.修仙之路;
				if (me.getLevel() < 90) {
					maps = new Integer[] { 6, 8, 9, 13 };
				} else if (me.getLevel() < 100) {
					maps = new Integer[] { 6, 7, 18, 9, 18 };
				} else if (me.getLevel() < 110) {
					maps = new Integer[] { 6, 7, 15, 21 };
				} else {
					maps = new Integer[] { 15, 21, 17, 22 };
				}
				bossName = new String[] { "广成子", "赤精子", "玉鼎真人", "太乙真人", "黄龙真人",
						"惧留孙", "文殊天尊", "普贤真人", "慈航道人", "灵宝法师", "道行天尊", "道德真君",
						"云中子" };
				bossBmp = new String[] { "风流才子", "风流才子", "老头", "老头", "老头",
						"老头", "和尚", "和尚", "美女", "老头", "老头", "壮男", "风流才子" };
				monsterName = new String[] { "侍女", "侍卫", "童子", "童子", "剑侍",
						"侍女", "沙弥", "沙弥", "侍女", "童子", "侍卫", "侍女", "侍女" };
				monsterBmp = new String[] { "美女1", "士兵", "儿童", "儿童", "士兵",
						"美女1", "老头", "老头", "美女1", "儿童", "士兵", "美女1", "美女1" };
				defalutMsg.add("道友找我有什么事么!");

				expectTeamNum = 2;
				bossPhysicalAttack = 0.4;
				bossMagicAttack = 0.3;
				bossPhysicalAttackPercent = 0.75;
				bossMagicAttackPercent = 0.25;
				bossMagicAttackNum = 5;
				bossSuperPhysicalAttack = 10;
				bossSuperSpritAttack = 10;
				monsterPhysicalAttack = 0.2;
				monsterMagicAttack = 0.15;
				monsterPhysicalAttackPercent = 1;
				monsterMagicAttackPercent = 0;
				monsterSuperPhysicalAttack = 5;
				monsterSuperSpritAttack = 5;
				equipLevel = 6;
			}
			// 领取条件判断:等级，人数，有未完成任务
			MmochatTask myTask = me.getTaskByType(taskType);
			if (myTask != null
					&& myTask.getTaskState() == MmochatTaskStateType.已接) {
				// 任务超时检测
				if (myTask.isInvalid()) {
					me.getTasks().remove(myTask.getTaskId());
					// 下发删除任务
					Mmochat_4_12S taskPack = new Mmochat_4_12S();
					taskPack.setTaskId(myTask.getTaskId());
					MmochatUtil.sendCommonPack(me, taskPack);

					myTask = null;
				} else {
					return MmochatUtil.msgbox(req.getHallState(),
							"你已经领取了此任务,请先完成再来领取新任务!");
				}
			}
			List<MmochatPlayer> teamers = new ArrayList<MmochatPlayer>();
			if (me.isInTeam()) {
				MmochatTeam team = MmochatTeamService.teams.get(me.getTeamId());
				if (team == null) {
					me.leaveTeam();
					teamers.add(me);
				} else {
					for (Integer roleId : team.getMemberId().values()) {
						MmochatPlayer member = MmochatMainService.players
								.get(roleId);
						if (member != null) {
							teamers.add(member);
						}
					}
				}
			} else {
				teamers.add(me);
			}
			if (teamers.size() < minTeamerNum) {
				return MmochatUtil.msgbox(req.getHallState(), "此行凶险,请至少"
						+ minTeamerNum + "人同行!");
			}
			for (MmochatPlayer member : teamers) {
				if (member.getLevel() < minLevel) {
					if (member == me) {
						return MmochatUtil.msgbox(req.getHallState(), "你年岁尚轻,请"
								+ minLevel + "级后再来找我!");
					} else {
						return MmochatUtil.msgbox(req.getHallState(), "队伍中"
								+ MmochatUtil.wrapColor(member.getName(),
										Color.yellow) + "年岁尚轻,还不能进行此修炼!");
					}
				}
			}
			if (me.getLevel() > maxLevel) {
				return MmochatUtil.msgbox(req.getHallState(), "你等级过高,无法领取此任务!");
			}
			// 获取轮次
			int turn;
			if (myTask == null) {
				// 第一次接此任务
				turn = 1;
			} else {
				turn = myTask.getTaskTurn();
			}
			long lifeTime = 40 * MmochatConstant.MS_PER_MINUTE;
			// 生成临时BOSS，生成临时任务,生成任务怪，将BOSS作为交任务NPC，再放置BOSS到地图
			MmochatTempNpc tmpNpc = new MmochatTempNpc(true);
			npcs.put(tmpNpc.getNpcId(), tmpNpc);
			tmpNpc.setLine(me.getLine());
			tmpNpc.setLevel(me.getLevel());
			tmpNpc.setLifeTime(lifeTime); // 40分钟的生命
			int nameIndex = MmochatUtil.getRandomValue(bossName.length);
			tmpNpc.setName(bossName[nameIndex]);
			tmpNpc.setDefaultMsg(defalutMsg);
			tmpNpc.setBmpType(MmochatRoleBmpType.valueOf(bossBmp[nameIndex]));
			int mapIndex = MmochatUtil.getRandomValue(maps.length);
			tmpNpc.setMapId(maps[mapIndex]);
			MmochatPoint point = MmochatMapService
					.getRandReachablePoint(maps[mapIndex]);
			if (point == null) {
				return MmochatUtil.msgbox(req.getHallState(), "请稍候再来!");
			}
			short x = (short) (point.getX() * 24 + Math.random() * 24);
			short y = (short) (point.getY() * 24 + Math.random() * 24);
			tmpNpc.setX(x);
			tmpNpc.setY(y);
			MmochatMap theMap = MmochatMapService.maps.get(maps[mapIndex]);
			if (theMap == null) {
				return MmochatUtil.msgbox(req.getHallState(), "请稍候再来!");
			}
			theMap.addNpc(tmpNpc.getLine(), tmpNpc);

			MmochatTempTask newTask = new MmochatTempTask(true);
			tmpNpc.addTask(newTask);
			newTask.setTaskName(type.toString());
			newTask.setTaskType(taskType);
			newTask.setTaskTurn(turn);
			newTask.setFinish_npcId(tmpNpc.getNpcId());
			newTask.setTaskLife(lifeTime);
			String detail = "第"
					+ turn
					+ "轮:请到"
					+ MmochatUtil.wrapColor(theMap.getMapName()
							+ (me.getLine() + 1) + "线(" + x + "," + y + ")",
							Color.yellow)
					+ MmochatUtil.wrapColor("击杀", Color.white)
					+ MmochatUtil.wrapColor(tmpNpc.getName(), Color.green);

			String taskDetail = detail
					+ "(各类急急如律令、天尊令、系统双倍有效；接任务后40分钟内未完成则任务失败)";
			newTask.setTaskDetail(taskDetail);

			MmochatNpcBattle battle = new MmochatNpcBattle();
			newTask.setFinish_need_battles(battle);
			MmochatMonsterFactory boss = new MmochatMonsterFactory();
			boss.setLevelType(MmochatBossLevelType.队长等级);
			boss.setBmpType(MmochatRoleBmpType.valueOf(bossBmp[nameIndex]));
			boss.setName(bossName[nameIndex]);
			boss.setLevel(me.getTrueLevel());
			boss.setEquipLevel(equipLevel);
			boss.setTeamNum(expectTeamNum);
			boss.setKillRound(3);
			boss.setPhysical(bossPhysicalAttack);
			boss.setMagic(bossMagicAttack);
			boss.setSuperPhysicalAttack(bossSuperPhysicalAttack);
			boss.setSuperSpritAttack(bossSuperSpritAttack);
			boss.setBossMaxSkillTargetNum(bossMagicAttackNum);
			boss.setSpeedPointAddType(3);
			MmochatAttackModeOfNormal defaultAttackMode = new MmochatAttackModeOfNormal();
			defaultAttackMode
					.setPhysicalAttackOpportunity((int) (100 * bossPhysicalAttackPercent));
			defaultAttackMode
					.setMagicAttackOppotunity((int) (100 * bossMagicAttackPercent));
			defaultAttackMode
					.setLimitOppotunity((int) (100 * (1 - bossMagicAttackPercent - bossPhysicalAttackPercent)));
			boss.setAttackMode_normal(defaultAttackMode);

			// 道行在1.5~2.5倍之间
			boss.setDao((int) ((1.5 + turn / 10.0) * MmochatBattleService
					.getStandardDao(me.getLevel(), me.getLife_turn())));
			boss.setAntiConfuse(turn);
			boss.setAntiFreeze(turn);
			boss.setAntiSeal(turn);
			battle.setBoss(boss);

			// 道具:如果使用了满卡，则小怪数+大怪数量固定为2XteamNum,
			int teamNum = teamers.size();
			int monsterNum = 0;
			if (me.hasPropEffect(MmochatPropType.顶级急急如律令.getEffectKey())) {
				monsterNum = teamNum * 5;
			} else if (me.hasPropEffect(MmochatPropType.特级急急如律令.getEffectKey())) {
				monsterNum = (int) (teamNum * 3.4);
			} else if (me.hasPropEffect(MmochatPropType.超级急急如律令.getEffectKey())) {
				monsterNum = (int) (teamNum * 2.5);
			} else if (me.hasPropEffect(MmochatPropType.急急如律令.getEffectKey())) {
				monsterNum = teamNum * 2;
			} else {
				monsterNum = teamNum + (int) (Math.random() * (teamNum + 1));
			}
			monsterNum = Math.min(10, monsterNum);
			monsterNum = monsterNum - 1;// 其中一个是主怪

			List<MmochatMonsterFactory> monsters = new ArrayList<MmochatMonsterFactory>();
			for (int i = 0; i < monsterNum; i++) {
				MmochatMonsterFactory monster = new MmochatMonsterFactory();
				monster.setLevelType(MmochatBossLevelType.队长等级);
				monster.setBmpType(MmochatRoleBmpType
						.valueOf(monsterBmp[nameIndex]));
				monster.setName(monsterName[nameIndex]);
				monster.setLevel(me.getTrueLevel());
				monster.setEquipLevel(equipLevel);
				monster.setTeamNum(expectTeamNum);
				monster.setKillRound(1);
				monster.setPhysical(monsterPhysicalAttack);
				monster.setMagic(monsterMagicAttack);
				monster.setSuperPhysicalAttack(monsterSuperPhysicalAttack);
				monster.setSuperSpritAttack(monsterSuperSpritAttack);
				monster.setBossMaxSkillTargetNum(2);
				monster.setSpeedPointAddType(0);
				MmochatAttackModeOfNormal attackMode = new MmochatAttackModeOfNormal();
				attackMode
						.setPhysicalAttackOpportunity((int) (100 * monsterPhysicalAttackPercent));
				attackMode
						.setMagicAttackOppotunity((int) (100 * monsterMagicAttackPercent));
				attackMode.setLimitOppotunity(0);
				monster.setAttackMode_normal(attackMode);
				// 道行在1~2倍之间
				monster.setDao((int) ((1 + turn / 10.0) * MmochatBattleService
						.getStandardDao(me.getLevel(), me.getLife_turn())));
				monsters.add(monster);
			}
			battle.setSmallBoss(monsters);

			Date now = new Date();
			MmochatPackageGrid prop = me
					.getPropGridFromPackage(MmochatPropType.飞羽);

			// 清除本队所有人的此类任务，复制并增加新的任务,并设置此任务为<已接>
			for (MmochatPlayer member : teamers) {
				MmochatTask t = member.getTaskByType(taskType);
				if (t != null) {
					member.getTasks().remove(t.getTaskId());
					// 下发删除任务
					Mmochat_4_12S taskPack = new Mmochat_4_12S();
					taskPack.setTaskId(t.getTaskId());
					MmochatUtil.sendCommonPack(member, taskPack);
				}
				MmochatTempTask tmpTask = newTask.getClone();
				tmpTask.setTaskState(MmochatTaskStateType.已接);
				member.addTask(tmpTask);

				// 下发增加任务
				Mmochat_4_11S pack = new Mmochat_4_11S();
				pack.setActionType(0);
				pack.setMe(me);
				pack.setTask(tmpTask);
				MmochatUtil.sendCommonPack(member, pack);

				if (member != me) {
					MmochatUtil.sendCommonMsgbox(member, detail);
				} else {
					if (prop == null
							|| (now.getDay() != 0 && now.getDay() != 6)) {
						CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
						msgbox.setContent(new Text(detail));
						msgbox.setLeftName("确定");
						msgbox.addLeftTLV(new CallLocalFuncTlv(
								MmochatConstant.funcode_worldPathFunc, tmpNpc
										.getMapId(), tmpNpc.getX(), tmpNpc
										.getY()));

						CtrlTLVStructureRequest tracePack = MmochatUtil
								.tlvResponseWithoutHallState(msgbox);
						MmochatUtil.sendCommonPack(member, tracePack);
					} else {
						// 有飞羽，询问是否直接飞去
						detail += "!\n"
								+ MmochatUtil.wrapIcon(MmochatPropType.飞羽
										.getBmpId())
								+ MmochatUtil.wrapColor("是否使用飞羽直达目的地?",
										Color.red);
						CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
						msgbox.setContent(new Text(detail));
						msgbox.setLeftName("使用");
						msgbox.setRightName("取消");
						msgbox.addRightTLV(new CallLocalFuncTlv(
								MmochatConstant.funcode_worldPathFunc, tmpNpc
										.getMapId(), tmpNpc.getX(), tmpNpc
										.getY()));

						msgbox.addLeftTLV(new ClearDataTLV());
						msgbox.addLeftTLV(new AddDataTLV((int) tmpNpc
								.getMapId()));
						msgbox.addLeftTLV(new AddDataTLV((int) tmpNpc.getX()));
						msgbox.addLeftTLV(new AddDataTLV((int) tmpNpc.getY()));
						msgbox.addLeftTLV(new SendDataTLV(MmochatConstant
								.getClientModuleId(), MmochatMain
								.getModuleInstID(),
								MmochatConstant.MSGCODE_MMOCHAT_C_9_62,
								(int) me.getRoleId()));
						ShowWaitingMsgBoxTLV wait = new ShowWaitingMsgBoxTLV();
						wait.setShowCancel(false);
						msgbox.addLeftTLV(wait);

						CtrlTLVStructureRequest msgboxPack = MmochatUtil
								.tlvResponseWithoutHallState(msgbox);
						MmochatUtil.sendCommonPack(member, msgboxPack);
					}
				}
			}
			break;
		}
		case 击杀: {
			List<MmochatPlayer> teamers = new ArrayList<MmochatPlayer>();
			boolean isTeamLeader = true;
			if (me.isInTeam()) {
				MmochatTeam team = MmochatTeamService.teams.get(me.getTeamId());
				if (team == null) {
					me.leaveTeam();
					teamers.add(me);
				} else {
					for (Integer roleId : team.getMemberId().values()) {
						MmochatPlayer member = MmochatMainService
								.getRoleFromBuffer(roleId);
						if (member != null) {
							teamers.add(member);
						}
					}
					if (me.getRoleId() != team.getTeamLeaderRoleId()) {
						isTeamLeader = false;
					}
				}
			} else {
				teamers.add(me);
			}
			if (!isTeamLeader) {
				return MmochatUtil.msgbox(req.getHallState(),
						"在队伍中只有队长才能进行此操作!");
			}

			// 检测NPC生命
			if (npc instanceof MmochatTempNpc) {
				MmochatTempNpc boss = (MmochatTempNpc) npc;
				if (boss.getState() == MmochatNpcState.战斗中
						&& System.currentTimeMillis() - boss.getCreateTime() < boss
								.getLifeTime()
								+ MmochatConstant.MS_PER_HOUR) {
					// 如果在战斗中，并且不超过生命时间+1小时，则不移除，等战斗结束时再移除
				} else if (boss.isTimeOut()) {
					boss.setState(MmochatNpcState.离开);
					npcs.remove(npc.getNpcId());
					MmochatMap curMap = MmochatMapService.maps.get(boss
							.getMapId());
					if (curMap != null) {
						// curMap.delNpc(boss.getLine(), npc);
						curMap.delNpc(npc);
					}
				}
			}

			if (npc instanceof MmochatActivityNpc) {
				// 战斗奖励在NPC中配置
				MmochatActivityNpc activeNpc = (MmochatActivityNpc) npc;
				// 人数判断
				if (teamers.size() < activeNpc.getMinTeamNum()) {
					return MmochatUtil.msgbox(req.getHallState(),
							"目标凶狠,为确保安全,请至少" + activeNpc.getMinTeamNum()
									+ "人组队!");
				}
				// 等级判断
				if (activeNpc.getMinLevel() != null) {
					int minLevelLimit = activeNpc.getMinLevel();
					for (MmochatPlayer member : teamers) {
						if (member.getLevel() < minLevelLimit) {
							return MmochatUtil.msgbox(req.getHallState(),
									minLevelLimit
											+ "级以上的人才能击杀!"
											+ (member == me ? "你" : member
													.getName()) + "的等级不够。");
						}
					}
				}

				if (activeNpc.getMaxLevel() != null) {
					int maxLevelLimit = activeNpc.getMaxLevel();
					for (MmochatPlayer member : teamers) {
						if (member.getLevel() > maxLevelLimit) {
							return MmochatUtil.msgbox(req.getHallState(),
									maxLevelLimit
											+ "级以下的人才能击杀!"
											+ (member == me ? "你" : member
													.getName()) + "的等级太高。");
						}
					}
				}

				if (activeNpc.getState() == MmochatNpcState.离开) {
					return MmochatUtil.msgbox(req.getHallState(), "目标已经离开!");
				} else if (activeNpc.getState() == MmochatNpcState.战斗中) {
					return MmochatUtil.msgbox(req.getHallState(),
							"目标正在战斗中,请稍候再来!");
				} else {
					MmochatNpcBattle battle = activeNpc.getBattle();
					if (battle == null) {
						return MmochatUtil
								.msgbox(req.getHallState(), "目标无法战斗!");
					}
					MmochatTask task = new MmochatTask();
					task.setTaskType(activeNpc.getBattleType());
					task.setFinish_need_battles(battle);

					// 进入战斗
					synchronized (activeNpc) {
						if (activeNpc.getState() == MmochatNpcState.空闲) {
							activeNpc.setState(MmochatNpcState.战斗中);
						} else if (activeNpc.getState() == MmochatNpcState.离开) {
							return MmochatUtil.msgbox(req.getHallState(),
									"目标已经离开!");
						} else if (activeNpc.getState() == MmochatNpcState.战斗中) {
							return MmochatUtil.msgbox(req.getHallState(),
									"目标正在战斗中,请稍候再来!");
						}
					}
					MmochatBattleService.enterNpcPk(me.getMapId(), (byte) me
							.getLine(), teamers, me.getRoleId(), task, req
							.getNpcId());
				}
			} else if (npc instanceof MmochatTempNpc) {
				// 战斗奖励在任务中配置
				MmochatTempNpc tmpNpc = (MmochatTempNpc) npc;
				if (teamers.size() < tmpNpc.getMinTeamNum()) {
					return MmochatUtil.msgbox(req.getHallState(),
							"目标凶狠,为确保安全,请至少" + tmpNpc.getMinTeamNum() + "人组队!");
				}
				if (tmpNpc.getState() == MmochatNpcState.离开) {
					return MmochatUtil.msgbox(req.getHallState(), "目标已经离开!");
				} else if (tmpNpc.getState() == MmochatNpcState.战斗中) {
					return MmochatUtil.msgbox(req.getHallState(),
							"目标正在战斗中,请稍候再来!");
				} else {
					MmochatTask task = tmpNpc.getTask(0);
					if (task != null) {
						if (task.getTaskType() == MmochatTaskType.击杀BOSS) {
							// 只有VIP才能杀
							List<MmochatPlayer> notVips = new ArrayList<MmochatPlayer>();
							for (MmochatPlayer player : teamers) {
								if (!player.hasPropEffect(MmochatPropType.会员周卡
										.getEffectKey())) {
									notVips.add(player);
								}
							}
							if (notVips.size() > 0) {
								String msg = "此BOSS只有会员才有权击杀";
								for (MmochatPlayer player : notVips) {
									msg += ",";
									if (player.getRoleId() == me.getRoleId()) {
										msg += "您";
									} else {
										msg += player.getName();
									}
								}
								msg += "不是会员,无法击杀。";
								return MmochatUtil.msgbox(req.getHallState(),
										msg);
							}
						} else if (task.getTaskType() == MmochatTaskType.击杀战神) {
							// 等级不能超过战神10级
							for (MmochatPlayer member : teamers) {
								if (member.getTrueLevel() > tmpNpc.getLevel() + 10) {
									for (MmochatPlayer he : teamers) {
										if (member == he) {
											MmochatUtil.sendCommonMsgbox(he,
													"您的等级超过我10级，无法挑战!");
										} else {
											MmochatUtil
													.sendCommonMsgbox(
															he,
															"队伍中"
																	+ MmochatUtil
																			.wrapColor(
																					member
																							.getName(),
																					Color.yellow)
																	+ "的等级超过战神10级，无法参与挑战!");
										}
									}
									return null;
								}
							}
						}

						if (task.needBattleBeforeFinish()) {

							// 进入战斗
							synchronized (tmpNpc) {
								if (tmpNpc.getState() == MmochatNpcState.空闲) {
									tmpNpc.setState(MmochatNpcState.战斗中);
								} else if (tmpNpc.getState() == MmochatNpcState.离开) {
									return MmochatUtil.msgbox(req
											.getHallState(), "目标已经离开!");
								} else if (tmpNpc.getState() == MmochatNpcState.战斗中) {
									return MmochatUtil.msgbox(req
											.getHallState(), "目标正在战斗中,请稍候再来!");
								}
							}
							MmochatBattleService.enterNpcPk(me.getMapId(),
									(byte) me.getLine(), teamers, me
											.getRoleId(), task, req.getNpcId());
						}
					}
				}
			}
			break;
		}
		case 挑战守护神: {
			if (MmochatGmService.isSystemExit()) {
				return MmochatUtil.msgbox(req.getHallState(),
						"服务器即将重启，暂时不能挑战守护神。");
			}
			List<MmochatPlayer> teamers = new ArrayList<MmochatPlayer>();
			if (me.isInTeam()) {
				MmochatTeam team = MmochatTeamService.teams.get(me.getTeamId());
				if (team == null) {
					me.leaveTeam();
					teamers.add(me);
				} else {
					for (Integer roleId : team.getMemberId().values()) {
						MmochatPlayer member = MmochatMainService
								.getRoleFromBuffer(roleId);
						if (member != null) {
							teamers.add(member);
						}
					}
				}
			} else {
				teamers.add(me);
			}

			// 战斗奖励在任务中配置
			if (teamers.size() != 5) {
				return MmochatUtil.msgbox(req.getHallState(),
						"我们不会以多欺少，你组满5人再来向我们挑战吧。");
			}
			MmochatMap map = MmochatMapService.maps.get(npc.getMapId());
			MmochatMapGuider guiderInfo = map.getMapGuiderInfo();
			if (guiderInfo == null) {
				return MmochatUtil.msgbox(req.getHallState(), "此地图还没有守护神!");
			}

			MmochatMapGuiderData guider = MmochatMapGuiderService.guiderPositions
					.get(npc.getMapId());
			if (guider == null) {
				return MmochatUtil.msgbox(req.getHallState(), "此地图没有守护神!");
			}
			List<MmochatTempNpc> npcList = guider.getNpcList();
			if (npcList == null || npcList.size() == 0) {
				return MmochatUtil.msgbox(req.getHallState(), "请稍候再来!");
			}
			MmochatTempNpc tmpNpc = null;
			try {
				tmpNpc = npcList.get(0);
			} catch (Exception e) {
			}
			if (tmpNpc == null) {
				return MmochatUtil.msgbox(req.getHallState(), "此地图没有守护神!");
			}
			MmochatTask task = tmpNpc.getTask(0);
			if (task != null) {
				// 条件判断:等级、战绩、时间限制
				String errInfo;
				String levelError = "", zhangJiError = "", timeError = "", turnError = "";
				Date now = new Date();
				now.setHours(0);
				now.setMinutes(0);
				now.setSeconds(0);
				long todayStartTime = now.getTime();// 今天0点0分0秒的时间点
				for (MmochatPlayer player : teamers) {
					if (player.getLevel() < guiderInfo.getMinLevel()
							|| player.getLevel() > guiderInfo.getMaxLevel()) {
						levelError += player.getName() + "、";
					}
					if (player.getZhanji() < MmochatConstant.zhanjiCostPerMapGuiderPk) {
						zhangJiError += player.getName() + "、";
					}
					// 余杭守护不限转生
					if (map.getMapId() != MmochatConstant.mapId_西岐) {
						if (player.getLife_turn() != guiderInfo
								.getLifeTurnNeed()) {
							turnError += player.getName() + "、";
						}
					}
					MmochatDailyActivity acvitity = player.getDailyActivities()
							.get(MmochatDailyActivityType.挑战地图守护神);
					if (acvitity != null
							&& acvitity.getLastTime() >= todayStartTime) {
						// 今天已经挑战过了
						timeError += player.getName() + "、";
					}
				}
				if (turnError.length() > 0) {
					errInfo = MmochatUtil.wrapColor(turnError, Color.green)
							+ "的转生次数不满足要求。本地图守护神只允许";
					if (guiderInfo.getLifeTurnNeed() == 0) {
						errInfo += "未转生";
					} else {
						errInfo += guiderInfo.getLifeTurnNeed() + "转";
					}
					errInfo += "的玩家挑战!";
					for (MmochatPlayer player : teamers) {
						MmochatUtil.sendCommonMsgbox(player, errInfo);
					}
					return null;
				}

				if (levelError.length() > 0) {
					errInfo = MmochatUtil.wrapColor(levelError, Color.green)
							+ "的等级不满足要求。本地图守护神只允许" + guiderInfo.getMinLevel()
							+ "级至" + guiderInfo.getMaxLevel() + "级之间的玩家挑战!";
					for (MmochatPlayer player : teamers) {
						MmochatUtil.sendCommonMsgbox(player, errInfo);
					}
					return null;
				}

				if (zhangJiError.length() > 0) {
					errInfo = MmochatUtil.wrapColor(zhangJiError, Color.green)
							+ "的战绩不足，挑战守护神需要花费"
							+ MmochatConstant.zhanjiCostPerMapGuiderPk + "点战绩。";
					for (MmochatPlayer player : teamers) {
						MmochatUtil.sendCommonMsgbox(player, errInfo);
					}
					return null;
				}

				if (timeError.length() > 0) {
					errInfo = MmochatUtil.wrapColor(timeError, Color.green)
							+ "今天已经挑战过了，地图守护神每天只能挑战一次!";
					for (MmochatPlayer player : teamers) {
						MmochatUtil.sendCommonMsgbox(player, errInfo);
					}
					return null;
				}

				if (task.needBattleBeforeFinish()) {
					// 进入战斗
					MmochatBattle battle = MmochatBattleService
							.enterNpcPkWithMonsterData(me.getMapId(), (byte) me
									.getLine(), teamers, me.getRoleId(), task,
									req.getNpcId());

					// 不允许逃跑
					if (battle != null) {
						battle.setCanEscape(false);
					} else {
						return MmochatUtil.msgbox(req.getHallState(), "请稍候再来!");
					}
				}
			}

			break;
		}
		case 挑战规则及奖励: {
			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinType(WinType.Text);
			tlv.setRightName("返回");
			tlv.setTitle("规则及奖励");
			tlv.setWinHeight(188);
			tlv.addRightTLV(new CloseWinTLV());
			String content = "";
			content += MmochatUtil.wrapColor("[挑战规则]", Color.green);
			content += "\n每天只能挑战一次，必需组满5人进行挑战。挑战需要扣除100点战绩，挑战成功将获得大量道行，"
					+ "并当其它玩家挑战你们失败时，你们会得到额外的道行奖励，此奖励在其它玩家取代你们时进行发放。"
					+ "挑战失败也能获得较多道行。\n\n";
			content += MmochatUtil.wrapColor("[挑战成功奖励]", Color.green);
			content += "\n成功打败守护神后，将获得"
					+ MmochatConstant.daoAwardOfWinMapGuiderPk
					+ "天道行奖励，"
					+ MmochatUtil.wrapColor(
							"和所有道行奖励一样，如果您的道行高于当前等级标准道行，道行天数会相应削减",
							Color.yellow) + "(标准道行：0.29X等级X等级X等级，单位：天)。"
					+ "挑战成功后，将取代原守护神成为新的守护神，" + "其它玩家继续挑战时，如果挑战失败，则每场你将额外获得"
					+ MmochatConstant.daoAwardOfMapGuiderPerPk + "天道行奖励。"
					+ "奖励会在最后守护神被其它玩家打败时进行发放。\n\n";
			content += MmochatUtil.wrapColor("[挑战失败奖励]", Color.green);
			content += "\n挑战失败也会获得" + MmochatConstant.daoAwardOfLoseMapGuiderPk
					+ "天道行的奖励，道行奖励受标准道行削减影响。";

			tlv.setContent(new Text(content));
			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		case 守护神分布: {
			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinType(WinType.Text);
			tlv.setRightName("返回");
			tlv.setTitle("守护神分布");
			tlv.setWinHeight(188);
			tlv.addRightTLV(new CloseWinTLV());
			String content = "";
			content += MmochatUtil.wrapColor("不限等级守护神\n", Color.yellow);
			content += "余杭(735,328)\n\n";
			content += MmochatUtil.wrapColor("30-39级守护神\n", Color.yellow);
			content += "南郊(247,315)\n\n";
			content += MmochatUtil.wrapColor("40-49级守护神\n", Color.yellow);
			content += "九幽(96,180)\n\n";
			content += MmochatUtil.wrapColor("50-59级守护神\n", Color.yellow);
			content += "岐山(328,344)\n\n";
			content += MmochatUtil.wrapColor("60-69级守护神\n", Color.yellow);
			content += "灵山(246,230)\n\n";
			content += MmochatUtil.wrapColor("70-79级守护神\n", Color.yellow);
			content += "东海(222,462)\n\n";
			content += MmochatUtil.wrapColor("80-89级守护神\n", Color.yellow);
			content += "死海(112,501)\n\n";
			content += MmochatUtil.wrapColor("90-99级守护神\n", Color.yellow);
			content += "天山(235,301)\n\n";
			content += MmochatUtil.wrapColor("100-109级守护神\n", Color.yellow);
			content += "妖谷(352,350)\n\n";
			content += MmochatUtil.wrapColor("110-119级守护神\n", Color.yellow);
			content += "天外(209,399)\n\n";
			content += MmochatUtil.wrapColor("120-129级守护神\n", Color.yellow);
			content += "地狱一层(568,450)\n\n";
			content += MmochatUtil.wrapColor("一转守护神\n", Color.yellow);
			content += "地狱二层(360,316)\n\n";
			content += MmochatUtil.wrapColor("二转守护神\n", Color.yellow);
			content += "地狱三层(406,368)\n\n";
			content += MmochatUtil.wrapColor("三转以上守护神\n", Color.yellow);
			content += "天机不可泄漏";

			tlv.setContent(new Text(content));
			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		case 门派试炼: {
			int minLevel = 30, maxLevel = MmochatConstant.maxLevel;
			MmochatTaskType taskType = MmochatTaskType.门派试炼;

			// 如果有多个门派试炼任务，则只保留轮次较高的一个
			List<MmochatTask> ts = new ArrayList<MmochatTask>();
			int maxTurn = -1;
			int saveTaskId = 0;
			for (MmochatTask t : me.getTasks().values()) {
				if (t.getTaskType() == taskType) {
					ts.add(t);
					if (t.getTaskTurn() >= maxTurn) {
						maxTurn = t.getTaskTurn();
						saveTaskId = t.getTaskId();
					}
				}
			}
			if (ts.size() >= 2) {
				for (MmochatTask t : ts) {
					if (t.getTaskId() != saveTaskId) {
						me.getTasks().remove(t.getTaskId());

						// 下发删除任务
						Mmochat_4_12S taskPack = new Mmochat_4_12S();
						taskPack.setTaskId(t.getTaskId());
						MmochatUtil.sendCommonPack(me, taskPack);
					}
				}
			}

			// 领取条件判断:等级，人数，有未完成任务
			MmochatTask myTask = me.getTaskByType(taskType);
			if (myTask != null
					&& myTask.getTaskState() == MmochatTaskStateType.已接) {
				// 交任务,检测任务是否完成
				// 交任务领取奖励后，任务设置完成，turn++，满轮后turn=1
				if (!myTask.canFinish(me)) {
					return MmochatUtil.msgbox(req.getHallState(),
							"你还没有完成我给你的任务呢，请先去完成!要是忘了任务内容，按4键查看吧!");
				}
				myTask.finishTask(me);

				// 下发删除任务
				Mmochat_4_12S taskPack = new Mmochat_4_12S();
				taskPack.setTaskId(myTask.getTaskId());
				MmochatUtil.sendCommonPack(me, taskPack);

				// 一轮完成
				boolean finishTurn = false;
				int curTurn = myTask.getTaskTurn();
				if (curTurn >= myTask.getTaskMaxTurn()) {
					// 一轮完成，更新每日任务
					finishTurn = true;
					MmochatDailyActivity activity = me.getDailyActivities()
							.get(MmochatDailyActivityType.门派试炼);
					if (activity == null) {
						// 第一次参加此活动
						activity = new MmochatDailyActivity();
						activity.setType(MmochatDailyActivityType.门派试炼);
						me.addDailyActivity(activity);
					}
					activity.setLastTime(System.currentTimeMillis());
					try {
						MmochatDao.updateRoleDailyActivity(me);
					} catch (Exception e) {
						e.printStackTrace();
					}
				}

				// 增加奖励，并下发提示
				int daoAward = (int) (curTurn * MmochatConstant.baseDaoAwardOfFamilyTrain);
				int expAward = 0;
				Map<MmochatRoleAttributeType, Double> attrMap = MmochatPetService.monsterBaseAttackData
						.get(me.getTrueLevel());
				if (attrMap != null) {
					expAward = (int) (curTurn
							* attrMap.get(MmochatRoleAttributeType.杀死怪物经验) * MmochatConstant.baseExpAwardOfFamilyTrain);
				}

				boolean uplevel = me.addExp(expAward);
				String msg = "你获得了"
						+ MmochatUtil.wrapColor(expAward, Color.green) + "点经验!";
				if (uplevel) {
					msg += "你升到" + me.getLevel() + "级了!";
				}

				MmochatPet pet = me.getPkPet();
				if (pet != null) {
					if (pet.getLevel() >= me.getLevel()
							+ MmochatConstant.zeroAwardOfPetLevelMoreThanOwner) {
						msg += "你的"
								+ pet.getName()
								+ "高于您"
								+ MmochatConstant.zeroAwardOfPetLevelMoreThanOwner
								+ "级,无法获得经验!";
					} else {
						int petLevel = pet.getTrueLevel();
						attrMap = MmochatPetService.monsterBaseAttackData
								.get(petLevel);
						if (attrMap != null) {
							expAward = (int) (curTurn
									* attrMap
											.get(MmochatRoleAttributeType.杀死怪物经验) * MmochatConstant.baseExpAwardOfFamilyTrain);

							pet.addExp(me, expAward);
							msg += "你的"
									+ pet.getName()
									+ "获得了"
									+ MmochatUtil.wrapColor(expAward,
											Color.green) + "点经验!";
						}
					}

				}
				if (!finishTurn) {
					int totalDaoAward = (int) ((1 + curTurn)
							* MmochatConstant.baseDaoAwardOfFamilyTrain
							* curTurn / 2);
					msg += "\n本次获得道行奖励" + daoAward + "天(削减前)，累计已获得"
							+ totalDaoAward
							+ "天(削减前)，道行奖励在本轮结束时发放，有机率超额获得5倍奖励和道具奖励!";
				} else {
					boolean lucky = MmochatUtil.isInPercent(7);
					int totalDaoAward = (int) ((1 + myTask.getTaskMaxTurn())
							* MmochatConstant.baseDaoAwardOfFamilyTrain
							* myTask.getTaskMaxTurn() / 2);
					if (lucky) {
						totalDaoAward = totalDaoAward * 5;
					}

					int totalDao = 0;
					int year = totalDaoAward / 365;
					for (int i = 0; i < year; i++) {
						// 刷道比赛
						MmochatPropService.dealDaoActivity(me, 365);
						int trueDao = MmochatBattleService.getRealDao(me, 365);
						me.addDao(trueDao);
						totalDao += trueDao;
					}
					msg += MmochatUtil.wrapColor("\n本轮已完成，你共获得" + totalDao
							+ "天道行(削减前" + totalDaoAward + "天)!", Color.yellow);
					if (lucky) {
						String context = MmochatUtil.wrapColor(me.getName(),
								Color.green)
								+ "在完成门派试炼时，意外得获得了"
								+ totalDao
								+ "天(削减前"
								+ totalDaoAward + "天)道行!快到门派找传送门童试炼吧~";
						MmochatChatService.sendSystemMsg(context);
					}

					try {
						int propPercent;
						if (me.isVip()) {
							propPercent = 5;
						} else {
							propPercent = 1;
						}
						boolean superLucky = MmochatUtil
								.isInPercent(propPercent);
						if (superLucky) {
							MmochatPropType[] propList = new MmochatPropType[] {
									MmochatPropType.会员周卡, MmochatPropType.会员月卡,
									MmochatPropType.大血瓶, MmochatPropType.系统双倍令,
									MmochatPropType.天尊令, MmochatPropType.道尊令,
									MmochatPropType.驱兽令, MmochatPropType.小血瓶,
									MmochatPropType.超级自动战斗令,
									MmochatPropType.女娲石, MmochatPropType.金钱袋,
									MmochatPropType.江湖名号, MmochatPropType.脱胎换骨水 };
							int index = MmochatUtil
									.getRandomValue(propList.length);
							MmochatPropType hitPropType = propList[index];
							MmochatProp prop = new MmochatProp(hitPropType);
							prop.setCanDeal(false);
							me.addObjectToPackage(prop);
							msg += MmochatUtil.wrapColor("\n你获得了1个"
									+ hitPropType.toString() + "!", Color.red);

							String context = MmochatUtil.wrapColor(
									me.getName(), Color.green)
									+ "在完成门派试炼时，幸运得获得了1个"
									+ MmochatUtil.wrapColor(hitPropType
											.toString(), Color.red)
									+ "!快到门派找传送门童试炼吧~";
							MmochatChatService.sendSystemMsg(context);
						}
					} catch (Exception e) {
						e.printStackTrace();
					}
				}
				// 更新头像图标信息
				Mmochat_1_7S pack = new Mmochat_1_7S();
				pack.setMe(me);
				MmochatUtil.sendCommonPack(me, pack);

				myTask.addTaskTurn();

				// 放入队列中
				if (!MmochatTaskService.needToSaveTaskSqlPlayerQueue
						.contains(me)
						&& !MmochatGmService.isSystemExit()) {
					MmochatTaskService.needToSaveTaskSqlPlayerQueue.add(me);
				}
				MmochatChatService.sendSystemMsgToPerson(me, msg);
				return MmochatUtil.msgbox(req.getHallState(), msg);
			}

			// 判断今天能否再接任务
			Date now = new Date();
			now.setHours(0);
			now.setMinutes(0);
			now.setSeconds(0);
			long todayStartTime = now.getTime();// 今天0点0分0秒的时间点

			MmochatDailyActivity acvitity = me.getDailyActivities().get(
					MmochatDailyActivityType.门派试炼);
			if (acvitity != null && acvitity.getLastTime() >= todayStartTime) {
				// 今天已经挑战过了
				return MmochatUtil.msgbox(req.getHallState(),
						"你今天已经完成了一轮试炼，请明天再来!");
			}

			if (me.getLevel() < minLevel) {
				return MmochatUtil.msgbox(req.getHallState(), "你年岁尚轻,请"
						+ minLevel + "级后再来找我!");
			}
			if (me.getLevel() > maxLevel) {
				return MmochatUtil.msgbox(req.getHallState(), "你等级过高,无法领取此任务!");
			}
			// 获取轮次
			int turn;
			if (myTask == null) {
				// 第一次接此任务
				turn = 1;
			} else {
				turn = myTask.getTaskTurn();
			}

			// 新的一轮任务开始，判断是否为会员
			if (turn == 1) {
				// 会员才能领取
				if (!isFamilyTrainOpenToday()) {
					if (!me.isVip()) {
						return MmochatUtil.msgbox(req.getHallState(),
								"只有门派精英才有资格进行门派试炼!使用会员周卡或会员月卡即可升级为门派精英。");
					}
				}
			}

			if (myTask != null) {
				me.getTasks().remove(myTask.getTaskId());
				// 下发删除任务
				Mmochat_4_12S taskPack = new Mmochat_4_12S();
				taskPack.setTaskId(myTask.getTaskId());
				MmochatUtil.sendCommonPack(me, taskPack);
			}

			MmochatTempTask newTask = new MmochatTempTask(true);
			newTask.setAccept_time(System.currentTimeMillis());
			newTask.setTaskName(type.toString());
			newTask.setTaskType(taskType);
			newTask.setTaskTurn(turn);
			newTask.setTaskMaxTurn(MmochatConstant.maxTurnOfFamilyTrain);
			newTask.setTaskLife(3650 * MmochatConstant.MS_PER_DAY);
			newTask.setFinish_npcId(npc.getNpcId());

			String detail = "";
			int index = MmochatUtil.getRandomValue(4);
			switch (index) {
			case 0: {
				// 收集材料类
				MmochatMaterialType materialType = MmochatMaterialType
						.getRandomMaterial(me.getLevel());
				int num = MmochatUtil.getRandomValue(3, 6);
				MmochatMaterial material = new MmochatMaterial();
				material.setMaterialType(materialType);
				material.setNum(num);
				newTask.addFinish_need_material(material);
				detail += "请替本派收集以下材料:" + num + "个" + materialType.toString()
						+ "(特定野怪机率掉落)!";
				break;
			}
			case 1: {
				// 收集药品类
				MmochatDrugType drugType = MmochatDrugType.getRandomDrug(me
						.getLevel());
				int num = MmochatUtil.getRandomValue(3, 10);
				MmochatDrug drug = new MmochatDrug();
				drug.setDrugType(drugType);
				drug.setNum(num);
				newTask.addFinish_need_drug(drug);
				detail += "请替本派收集以下药品:" + num + "个" + drugType.toString()
						+ "(城内药店有售)!";
				break;
			}
			case 2: {
				// 打怪类
				MmochatRoleType monsterType = MmochatRoleType
						.getRandomMonsterType(me.getLevel());
				int num = MmochatUtil.getRandomValue(3, 10);
				MmochatKillMonster killMonster = new MmochatKillMonster();
				killMonster.setMonsterType(monsterType);
				killMonster.setMonsterNum(num);
				newTask.getKillList().add(killMonster);
				detail += "请替本派击杀怪物:" + num + "个" + monsterType.toString()
						+ "!";
				break;
			}
			case 3: {
				// 战绩
				int num = MmochatUtil.getRandomValue(20, 50);
				newTask.setFinish_need_zhanji(num);
				detail += "请为本派贡献战绩:" + num + "点战绩!";
				break;
			}
			default:
				break;
			}
			String taskDetail = MmochatUtil.wrapColor("[第" + turn + "/"
					+ MmochatConstant.maxTurnOfFamilyTrain + "轮]", Color.green)
					+ MmochatUtil.wrapColor(detail, Color.yellow);

			newTask.setTaskDetail(taskDetail);

			newTask.setTaskState(MmochatTaskStateType.已接);
			me.addTask(newTask);

			// 下发增加任务
			Mmochat_4_11S pack = new Mmochat_4_11S();
			pack.setActionType(0);
			pack.setMe(me);
			pack.setTask(newTask);
			MmochatUtil.sendCommonPack(me, pack);
			return MmochatUtil.msgbox(req.getHallState(), taskDetail
					+ "完成后找我领取奖励，轮次越高，奖励越丰厚!");
		}
		case 挑战本派最强: {
			if (MmochatGmService.isSystemExit()) {
				return MmochatUtil.msgbox(req.getHallState(),
						"服务器即将重启，暂时不能挑战本派最强。");
			}
			List<MmochatPlayer> teamers = new ArrayList<MmochatPlayer>();
			if (me.isInTeam()) {
				return MmochatUtil.msgbox(req.getHallState(), "请不要组队!");
			} else {
				teamers.add(me);
			}

			// 战斗奖励在任务中配置
			MmochatMap map = MmochatMapService.maps.get(npc.getMapId());
			MmochatMapGuider guiderInfo = map.getMapGuiderInfo();
			if (guiderInfo == null) {
				return MmochatUtil.msgbox(req.getHallState(), "此地图没有相关NPC!原因1");
			}

			MmochatMapGuiderData guider = MmochatMapGuiderService.familyGuiderPositions
					.get(npc.getMapId());
			if (guider == null) {
				return MmochatUtil.msgbox(req.getHallState(), "此地图没有相关NPC!原因2");
			}
			List<MmochatTempNpc> npcList = guider.getNpcList();
			if (npcList == null || npcList.size() == 0) {
				return MmochatUtil.msgbox(req.getHallState(), "请稍候再来!");
			}
			MmochatTempNpc tmpNpc = null;
			try {
				tmpNpc = npcList.get(0);
			} catch (Exception e) {
			}
			if (tmpNpc == null) {
				return MmochatUtil.msgbox(req.getHallState(), "此地图没有相关NPC!原因3");
			}
			MmochatTask task = tmpNpc.getTask(0);
			if (task != null) {
				// 条件判断:等级、战绩、时间限制
				String errInfo;
				String levelError = "", zhangJiError = "", timeError = "";
				Date now = new Date();
				now.setHours(0);
				now.setMinutes(0);
				now.setSeconds(0);
				long todayStartTime = now.getTime();// 今天0点0分0秒的时间点
				for (MmochatPlayer player : teamers) {
					if (player.getLevel() < guiderInfo.getMinLevel()
							|| player.getLevel() > guiderInfo.getMaxLevel()) {
						levelError += player.getName() + "、";
					}
					if (player.getZhanji() < MmochatConstant.zhanjiCostPerMapGuiderPk) {
						zhangJiError += player.getName() + "、";
					}

					MmochatDailyActivity acvitity = player.getDailyActivities()
							.get(MmochatDailyActivityType.挑战本派最强);
					if (acvitity != null
							&& acvitity.getLastTime() >= todayStartTime) {
						// 今天已经挑战过了
						timeError += player.getName() + "、";
					}
				}
				if (levelError.length() > 0) {
					errInfo = MmochatUtil.wrapColor(levelError, Color.green)
							+ "的等级不满足要求。本派最强只允许" + guiderInfo.getMinLevel()
							+ "级至" + guiderInfo.getMaxLevel() + "级之间的玩家挑战!";
					for (MmochatPlayer player : teamers) {
						MmochatUtil.sendCommonMsgbox(player, errInfo);
					}
					return null;
				}

				if (zhangJiError.length() > 0) {
					errInfo = MmochatUtil.wrapColor(zhangJiError, Color.green)
							+ "的战绩不足，挑战本派最强需要花费"
							+ MmochatConstant.zhanjiCostPerMapGuiderPk + "点战绩。";
					for (MmochatPlayer player : teamers) {
						MmochatUtil.sendCommonMsgbox(player, errInfo);
					}
					return null;
				}

				if (timeError.length() > 0) {
					errInfo = MmochatUtil.wrapColor(timeError, Color.green)
							+ "今天已经挑战过了，本派最强每天只能挑战一次!";
					for (MmochatPlayer player : teamers) {
						MmochatUtil.sendCommonMsgbox(player, errInfo);
					}
					return null;
				}

				if (task.needBattleBeforeFinish()) {
					// 进入战斗
					MmochatBattle battle = MmochatBattleService
							.enterFamilyNpcPkWithMonsterData(me.getMapId(),
									(byte) me.getLine(), teamers, me
											.getRoleId(), task, req.getNpcId());

					// 不允许逃跑
					if (battle != null) {
						battle.setCanEscape(false);
					} else {
						return MmochatUtil.msgbox(req.getHallState(), "请稍候再来!");
					}
				}
			}

			break;
		}
		case 挑战说明: {
			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinType(WinType.Text);
			tlv.setRightName("返回");
			tlv.setTitle("挑战说明");
			tlv.setWinHeight(188);
			tlv.addRightTLV(new CloseWinTLV());
			String content = "";
			content += MmochatUtil.wrapColor("[挑战规则]", Color.green);
			content += "\n每天只能挑战一次，挑战时不允许组队。挑战需要扣除100点战绩，挑战成功将获得大量道行，"
					+ "并当其它玩家挑战你们失败时，你们会得到额外的道行奖励，此奖励在其它玩家取代你们时进行发放。"
					+ "挑战失败也能获得较多道行。\n\n";
			content += MmochatUtil.wrapColor("[挑战成功奖励]", Color.green);
			content += "\n成功打败本派最强后，将获得"
					+ MmochatConstant.daoAwardOfWinMapGuiderPk
					+ "天道行奖励，"
					+ MmochatUtil.wrapColor(
							"和所有道行奖励一样，如果您的道行高于当前等级标准道行，道行天数会相应削减",
							Color.yellow) + "(标准道行：0.29X等级X等级X等级，单位：天)。"
					+ "挑战成功后，您将成为新的本派最强并获得相应称号，" + "其它玩家继续挑战时，如果挑战失败，则每场你将额外获得"
					+ MmochatConstant.daoAwardOfMapGuiderPerPk + "天道行奖励。"
					+ "奖励会在最后您被其它玩家打败时进行发放。\n\n";
			content += MmochatUtil.wrapColor("[挑战失败奖励]", Color.green);
			content += "\n挑战失败也会获得" + MmochatConstant.daoAwardOfLoseMapGuiderPk
					+ "天道行的奖励，道行奖励受标准道行削减影响。";

			tlv.setContent(new Text(content));
			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		case 挑战经验锁妖塔:
		case 挑战道行锁妖塔: {
			if (me.getLevel() < MmochatConstant.minTowerLevel
					+ MmochatConstant.startTowerLevelReduce) {
				return MmochatUtil
						.msgbox(
								req.getHallState(),
								(MmochatConstant.minTowerLevel + MmochatConstant.startTowerLevelReduce)
										+ "级以后才能挑战锁妖塔!");
			}
			if (me.isInTeam()) {
				return MmochatUtil
						.msgbox(req.getHallState(), "锁妖塔为单人副本，请不要组队!");
			}

			int taskTag;
			String errHint = "";
			if (type == MmochatNpcItemType.挑战经验锁妖塔) {
				taskTag = MmochatConstant.taskTag_挑战经验通天塔;
				errHint = "您已经接受了道行锁妖塔的修炼，无法再接受其它类型的锁妖塔修炼!";
			} else {
				taskTag = MmochatConstant.taskTag_挑战道行通天塔;
				errHint = "您已经接受了经验锁妖塔的修炼，无法再接受其它类型的锁妖塔修炼!";
			}
			MmochatTask task = me.getTaskByType(MmochatTaskType.挑战锁妖塔);
			if (task == null) {
				// 第一次做这个活动

				// 扣除一定的战绩:等级X等级/10
				int needZhanJi = me.getTrueLevel() * me.getTrueLevel() / 10;
				if (me.getZhanji() < needZhanJi) {
					return MmochatUtil.msgbox(req.getHallState(),
							"进入锁妖塔修炼，需要消耗" + needZhanJi + "点战绩，您的战绩不足!");
				}
				me.addZhanji(-1 * needZhanJi);

				task = new MmochatTask();
				task.setTaskName("挑战锁妖塔");
				task.setTaskType(MmochatTaskType.挑战锁妖塔);
				task.setTaskState(MmochatTaskStateType.已接);
				task.setTaskLevel(me.getTrueLevel()
						- MmochatConstant.startTowerLevelReduce);
				task.setTaskTag(taskTag);
				task.setTaskLife(MmochatConstant.MS_PER_HOUR * 2);
				task.setTargetMapId(MmochatTowerService.getTowerMapIdByLevel(me
						.getTrueLevel()
						- MmochatConstant.startTowerLevelReduce));
				task.setFinish_npcId(MmochatTowerService
						.getTowerBaseNpcIdByLevel(me.getTrueLevel()
								- MmochatConstant.startTowerLevelReduce));
				String detail = MmochatTowerService.getTowerTaskDetailByLevel(
						me.getTrueLevel()
								- MmochatConstant.startTowerLevelReduce, task);
				task.setTaskDetail(detail);

				me.addTask(task);

				// 更新任务列表
				Mmochat_4_11S pack = new Mmochat_4_11S();
				pack.setActionType(0);
				pack.setMe(me);
				pack.setTask(task);
				MmochatUtil.sendCommonPack(me, pack);
				MmochatChatService.sendSystemMsgToPerson(me, "您消耗了"
						+ MmochatUtil.wrapColor(needZhanJi + "点", Color.green)
						+ "进入了锁妖塔副本!");
			} else if (task.getTaskState() == MmochatTaskStateType.已接) {
				// 已接任务
				if (taskTag != task.getTaskTag()) {
					return MmochatUtil.msgbox(req.getHallState(), errHint);
				}
			} else if (task.getTaskState() == MmochatTaskStateType.已完成) {
				Date now = new Date();
				now.setHours(0);
				now.setMinutes(0);
				now.setSeconds(0);
				if (task.getFinish_time() > now.getTime()) {
					// 今天完成的
					return MmochatUtil.msgbox(req.getHallState(),
							"您今天已经挑战过锁妖塔了，请明天再来!");
				} else {
					// 可以接新任务
					// 扣除一定的战绩:等级X等级/10
					int needZhanJi = me.getTrueLevel() * me.getTrueLevel() / 10;
					if (me.getZhanji() < needZhanJi) {
						return MmochatUtil.msgbox(req.getHallState(),
								"进入锁妖塔修炼，需要消耗" + needZhanJi + "点战绩，您的战绩不足!");
					}
					me.addZhanji(-1 * needZhanJi);

					task.setTaskName("挑战锁妖塔");
					task.setTaskState(MmochatTaskStateType.已接);
					task.setTaskLevel(me.getTrueLevel()
							- MmochatConstant.startTowerLevelReduce);
					task.setTaskTag(taskTag);
					task.setTaskLife(MmochatConstant.MS_PER_HOUR * 2);
					task.setTargetMapId(MmochatTowerService
							.getTowerMapIdByLevel(me.getTrueLevel()
									- MmochatConstant.startTowerLevelReduce));
					task.setFinish_npcId(MmochatTowerService
							.getTowerBaseNpcIdByLevel(me.getTrueLevel()
									- MmochatConstant.startTowerLevelReduce));
					String detail = MmochatTowerService
							.getTowerTaskDetailByLevel(me.getTrueLevel()
									- MmochatConstant.startTowerLevelReduce,
									task);
					task.setTaskDetail(detail);

					// 更新任务列表
					Mmochat_4_11S pack = new Mmochat_4_11S();
					pack.setActionType(0);
					pack.setMe(me);
					pack.setTask(task);
					MmochatUtil.sendCommonPack(me, pack);
					MmochatChatService.sendSystemMsgToPerson(me, "您消耗了"
							+ MmochatUtil.wrapColor(needZhanJi + "点",
									Color.green) + "进入了锁妖塔副本!");
				}
			}
			// 传送到指定任务层地图
			MmochatMap curMap = MmochatMapService.getMapByMapId(me.getMapId());
			MmochatMap newMap = MmochatMapService.getMapByMapId(task
					.getTargetMapId());
			MmochatMapService.tranToNewMap(curMap, me.getLine(), newMap, me
					.getLine(), 216, 158, me);
			break;
		}
		case 向镇妖护法请教: {
			// 检查是否组队；是否有进行中的镇妖任务；交任务NPC是否对上；
			if (me.isInTeam()) {
				return MmochatUtil.msgbox(req.getHallState(), "请单独前来，不要组队!");
			}
			MmochatTask task = me.getTaskByType(MmochatTaskType.挑战锁妖塔);
			if (task == null || task.getTaskState() != MmochatTaskStateType.已接) {
				return MmochatUtil.msgbox(req.getHallState(), "镇妖重地，闲人勿扰!");
			}
			if (MmochatTowerService.getTowerBaseNpcIdByMapId(task
					.getTargetMapId()) != npc.getNpcId()) {
				return MmochatUtil
						.msgbox(req.getHallState(), "请通过传送人到下一层进行挑战!");
			}
			MmochatMonsterFactory boss = MmochatTowerService.towerMonsters
					.get(me.getMapId());
			MmochatMonsterFactory pet = MmochatTowerService
					.getRandomTowerPetByLevel(me.getMapId(), boss.getDao());
			if (boss == null || pet == null) {
				return MmochatUtil.msgbox(req.getHallState(),
						"没有此层的战斗数据，请与客服联系!");
			}
			MmochatBattleService.enterTowerPk(me.getMapId(), (byte) me
					.getLine(), me, boss, pet);
			break;
		}
		case 前往下一层塔: {
			if (me.isInTeam()) {
				return MmochatUtil.msgbox(req.getHallState(), "请单独前来，不要组队!");
			}
			MmochatTask task = me.getTaskByType(MmochatTaskType.挑战锁妖塔);
			if (task == null || task.getTaskState() != MmochatTaskStateType.已接) {
				return MmochatUtil.msgbox(req.getHallState(), "镇妖重地，闲人勿入!");
			}

			if (MmochatConstant.npcId_towerTransNpcBase + task.getTargetMapId()
					- MmochatConstant.mapId_锁妖塔20级 == npc.getNpcId()) {
				return MmochatUtil.msgbox(req.getHallState(), "请先完成本层挑战!");
			}
			// 传送到指定任务层地图
			MmochatMap curMap = MmochatMapService.getMapByMapId(me.getMapId());
			MmochatMap newMap = MmochatMapService.getMapByMapId(task
					.getTargetMapId());
			MmochatMapService.tranToNewMap(curMap, me.getLine(), newMap, me
					.getLine(), 216, 158, me);
			break;
		}
		case 锁妖塔说明: {
			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinType(WinType.Text);
			tlv.setRightName("返回");
			tlv.setTitle("锁妖塔说明");
			tlv.setWinHeight(188);
			tlv.addRightTLV(new CloseWinTLV());
			String content = MmochatUtil.wrapColor("[简介]\n", Color.yellow);
			content += "锁妖塔是一个单人副本，传说塔有300层，每一层都镇妖护法把守。"
					+ "只有挑战成功前一层护法，才能进入到下一层塔挑战。\n\n";
			content += MmochatUtil.wrapColor("[规则]\n", Color.yellow);
			content += "每天只能挑战一次，经验塔和道行塔只能二选一进行挑战。挑战需要消耗一定战绩，不能组队前往。"
					+ "接受任务后，有2小时时间进行挑战，战斗失败、战斗逃跑，或时间结束都会结束任务，任务结束时进行奖励结算。"
					+ "在此期间可以放弃任务，放弃任务后当天可以重新挑战。挑战期间，可以自由传送出塔，任务不会结束。\n\n";
			content += MmochatUtil.wrapColor("[奖励和称号]\n", Color.yellow);
			content += "奖励与挑战成功的塔层数成正比。每个等级玩家中，挑战层数最高的一名将获得<镇妖护法>称号殊荣，"
					+ "并将成为该层塔的守护NPC。";

			tlv.setContent(new Text(content));
			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		case 购买初级药品:
		case 购买中级药品:
		case 购买高级药品: {
			Mmochat_13_4S pack = new Mmochat_13_4S();
			pack.setHallState(req.getHallState());
			pack.setShopType(MmochatShopType.金钱商店);
			pack.setVersion(MmochatConstant.shopClassVersion);
			pack.setUseInputBox(true);
			pack.setTitle(type.toString());
			pack.setMoney((int) me.getSmall_money());
			pack.setObjType(MmochatObjectType.药品);

			for (MmochatDrugType drugType : MmochatDrugType
					.getDrugListByLevel(type)) {
				Mmochat_13_4S.ShopObjInfo objInfo = pack.new ShopObjInfo();
				objInfo.setKey(drugType.getValue());
				objInfo.setEquipLevel(0);
				objInfo.setBmpId(drugType.getBmpId());
				objInfo.setSellInfo(drugType.getSellInfo());
				pack.addShopObj(objInfo);
			}
			return pack;
		}
		case 免费试药: {
			synchronized (me) {
				MmochatDailyActivity activity = me.getDailyActivities().get(
						MmochatDailyActivityType.免费试药);
				Date now = new Date();
				if (activity == null) {
					// 第一次参加此活动
					activity = new MmochatDailyActivity();
					activity.setType(MmochatDailyActivityType.免费试药);
					me.addDailyActivity(activity);
				} else {
					long lastTime = activity.getLastTime();
					if (now.getTime() - lastTime < MmochatConstant.MS_PER_DAY) {
						// 今天已经参加过此活动了
						return MmochatUtil.msgbox(req.getHallState(),
								"您今天已经试过药了,是药三分毒,请休息一下明天再来吧!");
					}
				}
				if (!me.hasEnoughPackageSpace(3)) {
					return MmochatUtil.msgbox(req.getHallState(),
							"请先将包裹清理出三个空位!");
				}
				now.setHours(0);
				now.setMinutes(0);
				now.setSeconds(1);
				activity.setLastTime(now.getTime());
			}

			String info;
			if (me.getLevel() < 10) {
				me.addDrugNoDeal(MmochatDrugType.活血草, 40);
				me.addDrugNoDeal(MmochatDrugType.甘湿草, 20);
				info = "你获得了40个活血草和20个甘湿草!我这里每天都会派送一些试用药品,如果没药了记得过来领噢!";
			} else {
				me.addDrugNoDeal(MmochatDrugType.补血丸, 40);
				me.addDrugNoDeal(MmochatDrugType.甘湿草, 20);
				info = "你获得了40个补血丸和20个甘湿草!我这里每天都会派送一些试用药品,如果没药了记得过来领噢!";
			}
			try {
				MmochatDao.updateFreeDrugActivity(me);
			} catch (Exception e) {
				e.printStackTrace();
				return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
			}
			return MmochatUtil.msgbox(req.getHallState(), info);
		}
		case 购买初级武器:
		case 购买中级武器:
		case 购买高级武器: {
			int minLevel = 0, maxLevel = MmochatConstant.equipMaxLevel;
			switch (type) {
			case 购买初级武器:
				minLevel = 0;
				maxLevel = 40;
				break;
			case 购买中级武器:
				minLevel = 40;
				maxLevel = 80;
				break;
			case 购买高级武器:
				minLevel = 80;
				maxLevel = MmochatConstant.equipMaxLevel;
				break;
			default:
				break;
			}
			Mmochat_13_4S pack = new Mmochat_13_4S();
			pack.setHallState(req.getHallState());
			pack.setShopType(MmochatShopType.金钱商店);
			pack.setVersion(MmochatConstant.shopClassVersion);
			pack.setUseInputBox(false);
			pack.setTitle(type.toString());
			pack.setMoney((int) me.getSmall_money());
			pack.setObjType(MmochatObjectType.装备);

			MmochatEquipType equipType = MmochatEquipType.武器;
			for (int equipLevel = minLevel; equipLevel <= maxLevel; equipLevel += 10) {
				Mmochat_13_4S.ShopObjInfo objInfo = pack.new ShopObjInfo();
				objInfo.setKey(equipType.getValue());
				objInfo.setEquipLevel(equipLevel);
				objInfo.setBmpId(equipType.getBmpId());

				MmochatEquip equip = MmochatEquipService.createRandomEquip(
						false, equipType, equipLevel,
						MmochatEquipQualityType.白装);
				String sellInfo = equip.getInfo()
						+ "\n"
						+ MmochatUtil.wrapColor("售价:"
								+ MmochatEquipService.getEquipPrice(equipType,
										equipLevel) + "文", new Color(232, 166,
								10));
				objInfo.setSellInfo(sellInfo);
				pack.addShopObj(objInfo);
			}
			return pack;
		}
		case 购买初级防具:
		case 购买中级防具:
		case 购买高级防具: {
			int minLevel = 0, maxLevel = MmochatConstant.equipMaxLevel;
			switch (type) {
			case 购买初级防具:
				minLevel = 0;
				maxLevel = 40;
				break;
			case 购买中级防具:
				minLevel = 40;
				maxLevel = 80;
				break;
			case 购买高级防具:
				minLevel = 80;
				maxLevel = MmochatConstant.equipMaxLevel;
				break;
			default:
				break;
			}
			Mmochat_13_4S pack = new Mmochat_13_4S();
			pack.setHallState(req.getHallState());
			pack.setShopType(MmochatShopType.金钱商店);
			pack.setVersion(MmochatConstant.shopClassVersion);
			pack.setUseInputBox(false);
			pack.setTitle(type.toString());
			pack.setMoney((int) me.getSmall_money());
			pack.setObjType(MmochatObjectType.装备);

			MmochatEquipType[] equips = new MmochatEquipType[] {
					MmochatEquipType.衣服, MmochatEquipType.头盔,
					MmochatEquipType.鞋子 };
			for (MmochatEquipType equipType : equips) {
				for (int equipLevel = minLevel; equipLevel <= maxLevel; equipLevel += 10) {
					Mmochat_13_4S.ShopObjInfo objInfo = pack.new ShopObjInfo();
					objInfo.setKey(equipType.getValue());
					objInfo.setEquipLevel(equipLevel);
					objInfo.setBmpId(equipType.getBmpId());

					MmochatEquip equip = MmochatEquipService.createRandomEquip(
							false, equipType, equipLevel,
							MmochatEquipQualityType.白装);
					String sellInfo = equip.getInfo()
							+ "\n"
							+ MmochatUtil.wrapColor("售价:"
									+ MmochatEquipService.getEquipPrice(
											equipType, equipLevel) + "文",
									new Color(232, 166, 10));
					objInfo.setSellInfo(sellInfo);
					pack.addShopObj(objInfo);
				}
			}
			return pack;
		}
		case 购买杂货: {
			Mmochat_13_4S pack = new Mmochat_13_4S();
			pack.setHallState(req.getHallState());
			pack.setShopType(MmochatShopType.金钱商店);
			pack.setVersion(MmochatConstant.shopClassVersion);
			pack.setUseInputBox(true);
			pack.setTitle("购买杂货");
			pack.setMoney((int) me.getSmall_money());
			pack.setObjType(MmochatObjectType.道具);

			for (MmochatPropType propType : MmochatPropType.values()) {
				if (!propType.isUseRMB()) {
					Mmochat_13_4S.ShopObjInfo objInfo = pack.new ShopObjInfo();
					objInfo.setKey(propType.getKey());
					objInfo.setEquipLevel(0);
					objInfo.setBmpId(propType.getBmpId());
					objInfo.setSellInfo(propType.getSellInfo());
					pack.addShopObj(objInfo);
				}
			}
			return pack;
		}
		case 回收物品: {
			Mmochat_9_11S pack = new Mmochat_9_11S();
			pack.setHallState(req.getHallState());
			return pack;
		}
		case 法伤榜:
		case 物伤榜:
		case 速度榜: {
			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinType(WinType.List);
			tlv.setLeftName("查看");
			tlv.setRightName("返回");
			tlv.setTitle(type.toString());
			tlv.setWinHeight(188);
			tlv.addRightTLV(new CloseWinTLV());
			for (int i = 30; i < 130; i += 10) {
				tlv.addItemEvent(i + "级-" + (i + 9) + "级榜", new ClearDataTLV(),
						new AddDataTLV((int) i));
			}
			tlv.addLeftTLV(new AddDataTLV((int) type.getValue()));
			tlv.addLeftTLV(new SendDataTLV(MmochatConstant.getClientModuleId(),
					MmochatMain.getModuleInstID(),
					MmochatConstant.MSGCODE_MMOCHAT_C_9_61, (int) me
							.getRoleId()));
			tlv.addLeftTLV(new ShowWaitingMsgBoxTLV());
			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		case 高手榜: {
			if (levelRank.size() == 0) {
				return MmochatUtil.msgbox(req.getHallState(),
						"暂时没有此项数据!此项数据每天更新一次!");
			}
			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinType(WinType.List);
			tlv.setRightName("返回");
			tlv.setTitle("高手榜");
			tlv.setWinHeight(188);
			tlv.addRightTLV(new CloseWinTLV());
			int rank = 1;
			for (MmochatRankPlayer player : levelRank) {
				String item = rank + ".";
				if (player.getRoleId() == me.getRoleId()) {
					item += MmochatUtil
							.wrapColor(player.getName(), Color.green);
				} else {
					item += MmochatUtil.wrapColor(player.getName(),
							Color.yellow);
				}
				item += "\n";
				if (player.getLife_turn() > 0) {
					item += player.getLife_turn() + "转-";
				}
				item += player.getLevel() + "级";
				tlv.addItemEvent(player.getBmpId(), item);
				rank++;
			}
			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		case 道行榜: {
			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinType(WinType.List);
			tlv.setLeftName("查看");
			tlv.setRightName("返回");
			tlv.setTitle("道行榜");
			tlv.setWinHeight(188);
			tlv.addRightTLV(new CloseWinTLV());
			tlv
					.addItemEvent("总榜", new ClearDataTLV(), new AddDataTLV(
							(int) -1));

			for (int i = 30; i < 130; i += 10) {
				tlv.addItemEvent(i + "级-" + (i + 9) + "级榜", new ClearDataTLV(),
						new AddDataTLV((int) i));
			}
			tlv.addLeftTLV(new SendDataTLV(MmochatConstant.getClientModuleId(),
					MmochatMain.getModuleInstID(),
					MmochatConstant.MSGCODE_MMOCHAT_C_9_20, (int) me
							.getRoleId()));
			tlv.addLeftTLV(new ShowWaitingMsgBoxTLV());
			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		case 财富榜: {
			if (moneyRank.size() == 0) {
				return MmochatUtil.msgbox(req.getHallState(),
						"暂时没有此项数据!此项数据每天更新一次!");
			}
			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinType(WinType.List);
			tlv.setRightName("返回");
			tlv.setTitle("富豪榜");
			tlv.setWinHeight(188);
			tlv.addRightTLV(new CloseWinTLV());
			int rank = 1;
			for (MmochatRankPlayer player : moneyRank) {
				String item = rank + ".";
				if (player.getRoleId() == me.getRoleId()) {
					item += MmochatUtil
							.wrapColor(player.getName(), Color.green);
				} else {
					item += MmochatUtil.wrapColor(player.getName(),
							Color.yellow);
				}
				item += "\n"
						+ (player.getSmall_money() + player
								.getStoredSmall_money()) + "文";
				tlv.addItemEvent(player.getBmpId(), item);
				rank++;
			}
			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		case 战绩榜: {
			if (zhanJiRank.size() == 0) {
				return MmochatUtil.msgbox(req.getHallState(),
						"暂时没有此项数据!此项数据每天更新一次!");
			}
			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinType(WinType.List);
			tlv.setRightName("返回");
			tlv.setTitle("战绩榜");
			tlv.setWinHeight(188);
			tlv.addRightTLV(new CloseWinTLV());
			int rank = 1;
			for (MmochatRankPlayer player : zhanJiRank) {
				String item = rank + ".";
				if (player.getRoleId() == me.getRoleId()) {
					item += MmochatUtil
							.wrapColor(player.getName(), Color.green);
				} else {
					item += MmochatUtil.wrapColor(player.getName(),
							Color.yellow);
				}
				item += "\n" + player.getZhanji() + "点";
				tlv.addItemEvent(player.getBmpId(), item);
				rank++;
			}
			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		case 学习法术技能:
		case 学习障碍技能:
		case 学习辅助技能: {
			int skillType = 0;
			String title = "";
			if (type == MmochatNpcItemType.学习法术技能) {
				skillType = 0;
				title = "法术技能";
			} else if (type == MmochatNpcItemType.学习障碍技能) {
				skillType = 1;
				title = "障碍技能";
			} else if (type == MmochatNpcItemType.学习辅助技能) {
				skillType = 2;
				title = "辅助技能";
			}
			MmochatFamilyType family = me.getFamily();
			List<MmochatSkillType> skills = new ArrayList<MmochatSkillType>();
			for (MmochatSkillType type1 : MmochatSkillType.values()) {
				if (type1.getSkillFamily() == family
						&& type1.getSkillType() == skillType) {
					skills.add(type1);
				}
			}
			if (skills.size() == 0) {
				return MmochatUtil.msgbox(req.getHallState(), "没有可以学习的技能!");
			}
			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinType(WinType.List);
			tlv.setLeftName("查看");
			tlv.setRightName("返回");
			tlv.setTitle(title);
			tlv.setWinHeight(188);
			tlv.setWinId(MmochatConstant.TLV_WIN_SKILL_LIST);
			tlv
					.addRightTLV(new CloseWinTLV(
							MmochatConstant.TLV_WIN_SKILL_LIST));

			for (MmochatSkillType skill : skills) {
				String item = skill.toString();
				int myLevel = me.getSkillLevel(skill);
				int maxLevel = skill.getMaxLevel();
				item += "(" + myLevel + "/" + maxLevel + ")";
				tlv.addItemEvent(item, new ClearDataTLV(), new AddDataTLV(
						(int) skill.getKey()));
			}
			tlv
					.addLeftTLV(new SendDataTLV(MmochatConstant
							.getClientModuleId(),
							MmochatMain.getModuleInstID(),
							MmochatConstant.MSGCODE_MMOCHAT_C_6_6, (int) me
									.getRoleId()));
			ShowWaitingMsgBoxTLV wait = new ShowWaitingMsgBoxTLV();
			tlv.addLeftTLV(wait);
			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		case 炼丹术: {
			String title = "炼丹术";
			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinType(WinType.List);
			tlv.setLeftName("查看");
			tlv.setRightName("返回");
			tlv.setTitle(title);
			tlv.setWinHeight(188);
			tlv.addRightTLV(new CloseWinTLV());

			for (MmochatLifeSkillType skill : MmochatLifeSkillType.values()) {
				String item = skill.toString();
				tlv.addItemEvent(item, new ClearDataTLV(), new AddDataTLV(
						(int) skill.getValue()));
			}
			tlv.addLeftTLV(new SendDataTLV(MmochatConstant.getClientModuleId(),
					MmochatMain.getModuleInstID(),
					MmochatConstant.MSGCODE_MMOCHAT_C_9_55, (int) me
							.getRoleId()));
			ShowWaitingMsgBoxTLV wait = new ShowWaitingMsgBoxTLV();
			tlv.addLeftTLV(wait);
			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		case 障碍技能说明: {
			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinType(WinType.Text);
			tlv.setRightName("返回");
			tlv.setTitle("障碍技能说明");
			tlv.setWinHeight(188);
			tlv.addRightTLV(new CloseWinTLV());
			String content = "障碍技能是一类控制技,用来限制对方的行动!\n\n";
			switch (me.getFamily()) {
			case 阐教: {
				content += "本派障碍技能以令对方失去自身意识为目的,成功障碍对方后,"
						+ "对方将无法使用技能与道具,但其仍有有可能产生无意识的物理攻击!\n\n";
				content += "障碍技能有一定成功率,成功率取决于彼此的道行,道行高于对方越多,则成功机率越高,且障碍状态保持的越久!"
						+ "当然装备中的强力遗忘与抗遗忘也会影响成功率!";
				break;
			}
			case 人教: {
				content += "本派障碍技能以令对方完全失去行动能力为目的,成功障碍对方后,"
						+ "对方将无法进行任何操作,但也不会再受到其它伤害!\n\n";
				content += "障碍技能有一定成功率,成功率取决于彼此的道行,道行高于对方越多,则成功机率越高,且障碍状态保持的越久!"
						+ "当然装备中的强力冰冻与抗冰冻也会影响成功率!";
				break;
			}
			case 截教: {
				content += "本派障碍技能以令对方迷失自我为目的,成功障碍对方后,"
						+ "对方有可能对其队友进行攻击,也可能仍然攻向本方,其攻击目标不受其自身控制!\n\n";
				content += "障碍技能有一定成功率,成功率取决于彼此的道行,道行高于对方越多,则成功机率越高,且障碍状态保持的越久!"
						+ "当然装备中的强力混乱与抗混乱也会影响成功率!";
				break;
			}
			default:
				break;
			}
			tlv.setContent(new Text(content));
			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		case 辅助技能说明: {
			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinType(WinType.Text);
			tlv.setRightName("返回");
			tlv.setTitle("辅助技能说明");
			tlv.setWinHeight(188);
			tlv.addRightTLV(new CloseWinTLV());
			String content = "辅助技能是一种加强本方人员战斗能力的技能!\n\n";
			switch (me.getFamily()) {
			case 阐教: {
				content += "本派辅助技能可以提升己方人员的出手速度!速度按百分比提升，技能等级越高，提升的百分比越大。"
						+ "速度决定先机，学好本教的辅助技能能让你在战斗中总是先人一步。";
				break;
			}
			case 人教: {
				content += "本派辅助技能可以提升己方人员的防御能力!防御按百分比提升，技能等级越高，提升的百分比越大。"
						+ "学好本教的辅助技能能让你拥有牢不可破的防御，在战斗中立于不败之地。";
				break;
			}
			case 截教: {
				content += "本派辅助技能可以提升己方人员的攻击伤害!攻击伤害按百分比提升，技能等级越高，提升的百分比越大。"
						+ "学好本教的辅助技能能让你在战场中乘风破浪，势不可挡。";
				break;
			}
			default:
				break;
			}
			tlv.setContent(new Text(content));
			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		case 前往江宁:
		case 前往开封:
		case 前往余杭:
		case 退出会场前往余杭:
		case 退出会场前往江宁:
		case 退出会场前往开封:
		case 前往比武场:
		case 前往地府:
		case 前往地狱一层:
		case 前往地狱二层:
		case 前往地狱三层:
		case 前往地狱四层:
		case 前往地狱五层:
		case 前往地狱六层:
		case 前往地狱七层:
		case 前往地狱八层:
		case 前往地狱九层:
		case 前往地狱十层: {
			if (me.hasYBTask()) {
				return MmochatUtil.msgbox(req.getHallState(),
						"押送镖银过程中无法进行传送!您需要先放弃或完成此任务!");
			}

			int targetMapId = 0;
			int targetX = 0, targetY = 0;
			int levelNeed = 0;
			int turnNeed = 0; // 转生要求
			String cityName = "";
			if (type == MmochatNpcItemType.前往江宁
					|| type == MmochatNpcItemType.退出会场前往江宁) {
				targetMapId = MmochatConstant.mapId_冀州;
				targetX = 404;
				targetY = 430;
				levelNeed = 30;
				cityName = "江宁";
			} else if (type == MmochatNpcItemType.前往开封
					|| type == MmochatNpcItemType.退出会场前往开封) {
				targetMapId = MmochatConstant.mapId_朝歌;
				targetX = 318;
				targetY = 540;
				levelNeed = 80;
				cityName = "开封";
			} else if (type == MmochatNpcItemType.前往余杭
					|| type == MmochatNpcItemType.退出会场前往余杭) {
				targetMapId = MmochatConstant.mapId_西岐;
				targetX = 412;
				targetY = 542;
				levelNeed = 0;
				cityName = "余杭";
			} else if (type == MmochatNpcItemType.前往比武场) {
				targetMapId = MmochatConstant.mapId_比武场;
				targetX = 195;
				targetY = 98;
				levelNeed = 10;
				cityName = "比武场";
				if (me.getLine() != 1) {
					return MmochatUtil.msgbox(req.getHallState(),
							"比武场只能由2线进入，请先切换到2线!");
				}
			} else if (type == MmochatNpcItemType.前往地府) {
				targetMapId = MmochatConstant.mapId_地府;
				targetX = 198;
				targetY = 99;
				levelNeed = 30;
				cityName = "地府";
			} else if (type == MmochatNpcItemType.前往地狱一层) {
				targetMapId = MmochatConstant.mapId_地狱一层;
				targetX = 434;
				targetY = 313;
				levelNeed = 100;
				cityName = "地狱一层";
			} else if (type == MmochatNpcItemType.前往地狱二层) {
				targetMapId = MmochatConstant.mapId_地狱二层;
				targetX = 353;
				targetY = 155;
				levelNeed = 120;
				turnNeed = 1;
				cityName = "地狱二层";
			} else if (type == MmochatNpcItemType.前往地狱三层) {
				targetMapId = MmochatConstant.mapId_地狱三层;
				targetX = 386;
				targetY = 558;
				levelNeed = 120;
				turnNeed = 2;
				cityName = "地狱三层";
			} else if (type == MmochatNpcItemType.前往地狱四层) {
				targetMapId = MmochatConstant.mapId_地狱四层;
				targetX = 434;
				targetY = 313;
				levelNeed = 120;
				turnNeed = 3;
				cityName = "地狱四层";
			} else if (type == MmochatNpcItemType.前往地狱五层) {
				targetMapId = MmochatConstant.mapId_地狱五层;
				targetX = 353;
				targetY = 155;
				levelNeed = 120;
				turnNeed = 4;
				cityName = "地狱五层";
			} else if (type == MmochatNpcItemType.前往地狱六层) {
				targetMapId = MmochatConstant.mapId_地狱六层;
				targetX = 386;
				targetY = 558;
				levelNeed = 120;
				turnNeed = 5;
				cityName = "地狱六层";
			} else if (type == MmochatNpcItemType.前往地狱七层) {
				targetMapId = MmochatConstant.mapId_地狱七层;
				targetX = 434;
				targetY = 313;
				levelNeed = 120;
				turnNeed = 6;
				cityName = "地狱七层";
			} else if (type == MmochatNpcItemType.前往地狱八层) {
				targetMapId = MmochatConstant.mapId_地狱八层;
				targetX = 353;
				targetY = 155;
				levelNeed = 120;
				turnNeed = 7;
				cityName = "地狱八层";
			} else if (type == MmochatNpcItemType.前往地狱九层) {
				targetMapId = MmochatConstant.mapId_地狱九层;
				targetX = 386;
				targetY = 558;
				levelNeed = 120;
				turnNeed = 8;
				cityName = "地狱九层";
			} else if (type == MmochatNpcItemType.前往地狱十层) {
				targetMapId = MmochatConstant.mapId_地狱十层;
				targetX = 386;
				targetY = 558;
				levelNeed = 120;
				turnNeed = 9;
				cityName = "地狱十层";
			}
			if (me.getMapId() == targetMapId) {
				log.debug("玩家" + me.getName() + "(skyid=" + me.getSkyId()
						+ ")已经在mapId=" + me.getMapId() + "的地图了!,无需传送");
				break;
			}
			if (me.isInBattle()) {
				log.debug("玩家" + me.getName() + "(skyid=" + me.getSkyId()
						+ ")已进入战斗,无法传送");
				break;
			}

			List<MmochatPlayer> members = new ArrayList<MmochatPlayer>();
			if (me.isInTeam()) {
				MmochatTeam team = MmochatTeamService.teams.get(me.getTeamId());
				if (team == null) {
					me.leaveTeam();
					members.add(me);
				} else {
					if (!team.isTeamLeader(me.getRoleId())) {
						log.debug("玩家" + me.getName() + "(skyid="
								+ me.getSkyId() + ")在队伍中，且不为队长，无法传送;");
						break;
					}
					for (Integer roleId : team.getMemberId().values()) {
						MmochatPlayer member = MmochatMainService.players
								.get(roleId);
						if (member != null) {
							members.add(member);
						}
					}
				}
			} else {
				members.add(me);
			}
			if (members.size() <= 0) {
				log.debug("玩家" + me.getName() + "(skyid=" + me.getSkyId()
						+ ")传送人数为0，无法传送;");
				break;
			}

			for (MmochatPlayer member : members) {
				if (member.getLevel() < levelNeed) {
					return MmochatUtil.msgbox(req.getHallState(), levelNeed
							+ "级以后才能去" + cityName + "!" + member.getName()
							+ "的等级不够。");
				}
				if (member.getLife_turn() < turnNeed) {
					return MmochatUtil.msgbox(req.getHallState(), turnNeed
							+ "次转生后才能前往" + cityName + "!" + member.getName()
							+ "的转生条件不符。");
				}
			}

			// 通过x,y决定传送到哪个地图哪个传送口附近
			MmochatMap curMap = MmochatMapService.getMapByMapId(me.getMapId());
			MmochatMap newMap = MmochatMapService.getMapByMapId(targetMapId);
			if (newMap == null) {
				return MmochatUtil.msgbox(req.getHallState(), "此地图暂未开放!无法前往!");
			}

			// 将本队人马传到新地图新坐标
			for (MmochatPlayer member : members) {
				// TODO:其它处理
				if (!member.lockState(MmochatRoleStateType.切换地图时)) {
					log.debug("玩家" + member.getName() + "(skyid="
							+ me.getSkyId() + ")当前状态为<"
							+ member.getState().toString() + ">,无法传送");
					continue;
				}
				if (member.isInBattle()) {
					member.unLockState();
					continue;
				}

				if (type == MmochatNpcItemType.退出会场前往余杭
						|| type == MmochatNpcItemType.退出会场前往江宁
						|| type == MmochatNpcItemType.退出会场前往开封) {
					// 积分清0
					member.setCommonActivityScore(0);
				}

				// 停止交易
				member.stopDeal();

				// 清除周围玩家
				member.getSceenRoles().clear();

				// 清除坐标缓存器
				member.getPositionBuffer().clear();

				// 清除NPC列表
				member.getTmpNpcs().clear();

				// 从旧的地图中移除
				if (newMap.getMapId() != curMap.getMapId()) {
					curMap.delRole(member.getLine(), member);
				}

				// 设置新坐标
				member.setX(targetX);
				member.setY(targetY);
				member.setMapId(targetMapId);

				member.unLockState();

				Mmochat_1_1S pack = new Mmochat_1_1S();
				// 不使用hallState进行判断,以免终端连续上传两次请求后,终端hallState被第二次请求发送时更改
				pack.setMap(newMap);
				pack.setLine((int) me.getLine());
				pack.setMe(member);
				MmochatMainService.enterGame(member, member.getUserConnInfo(),
						pack);
				synchronized (member) {
					// 坐标可能被其它线程修改，用同步保护
					member.setX(targetX);
					member.setY(targetY);
					MmochatUtil.sendCommonPack(member, pack);
				}
				if (curMap.getMapId() != newMap.getMapId()) {
					try {
						if (type == MmochatNpcItemType.退出会场前往余杭
								|| type == MmochatNpcItemType.退出会场前往江宁
								|| type == MmochatNpcItemType.退出会场前往开封) {
							// MmochatDao.updateRoleLeavePkGame(member);
						} else {
							MmochatDao.updateRoleEnterNewMap(member);
						}
					} catch (Exception e) {
						e.printStackTrace();
					}
				}
				if (type == MmochatNpcItemType.前往比武场) {
					String msg;
					msg = "您已进入比武场。在场内切磋要求战绩不低于"
							+ MmochatConstant.minZhangJiNeedInPkMap
							+ "，输方扣除一定战绩，赢方获得相应战绩。";
					MmochatChatService.sendSystemMsgToPerson(member, msg);
				}
				if (type == MmochatNpcItemType.前往地府) {
					String msg;
					msg = "您已进入地府。服用鬼灵珠(商城有售)后，在地府打怪可以获得道行奖励。"
							+ "地府怪物较强，请注意人身安全!";
					MmochatChatService.sendSystemMsgToPerson(member, msg);
				}
			}
			log
					.debug("玩家" + me.getName() + "(skyid=" + me.getSkyId()
							+ ")完成传送");
			return null;
		}
		case 历届天下第一: {
			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinType(WinType.List);
			tlv.setRightName("返回");
			tlv.setTitle("历届天下第一");
			tlv.setWinHeight(228);
			tlv.addRightTLV(new CloseWinTLV());

			SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");

			for (MmochatEventLog eventLog : eventLogList) {
				if (eventLog.getType() == MmochatEventType.天下第一争霸赛) {
					String item = fmt.format(new Date(eventLog.getTime()));
					item += "\n"
							+ MmochatUtil.wrapColor(eventLog.getContent(),
									Color.yellow);
					tlv.addItemEvent(item);
				}
			}
			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		case 参加天下第一争霸赛: {
			// 30级:1线; 40级:2线; ..., 110级:9线; 120级:10线
			// 武道会的战斗系统由MmochatScheduleJobService触发实现
			Date now = new Date();
			if (me.getLevel() < 30) {
				return MmochatUtil.msgbox(req.getHallState(),
						"30级以上才能参加天下第一争霸赛!");
			}
			if (now.getDay() != 6 || now.getHours() != 19
					|| now.getMinutes() < 40) {
				return MmochatUtil.msgbox(req.getHallState(),
						"天下第一争霸赛入场时间:每周六19:40-20:00,现在不是入场时间!");
			}

			if (me.getLine() != MmochatNo1PkGame.pkLine) {
				return MmochatUtil.msgbox(req.getHallState(), "天下第一争霸赛在"
						+ (MmochatNo1PkGame.pkLine + 1) + "线举行!");
			}
			// 进入比武场
			int targetMapId = MmochatConstant.mapId_天下第一赛场;
			MmochatMap newMap = MmochatMapService.getMapByMapId(targetMapId);
			if (newMap == null) {
				return MmochatUtil.msgbox(req.getHallState(), "会场尚未准备好,请稍候再来!");
			}

			// 地图传送目的地
			int targetX = 235, targetY = 290;
			if (me.getMapId() == targetMapId) {
				log.debug("玩家" + me.getName() + "(skyid=" + me.getSkyId()
						+ ")已经在mapId=" + me.getMapId() + "的地图了!,无需传送");
				break;
			}
			if (me.isInBattle()) {
				log.debug("玩家" + me.getName() + "(skyid=" + me.getSkyId()
						+ ")已进入战斗,无法传送");
				break;
			}
			List<MmochatPlayer> members = new ArrayList<MmochatPlayer>();
			if (me.isInTeam()) {
				return MmochatUtil.msgbox(req.getHallState(), "不能组队入场!");
			} else {
				members.add(me);
			}
			if (members.size() <= 0) {
				log.debug("玩家" + me.getName() + "(skyid=" + me.getSkyId()
						+ ")传送人数为0，无法传送;");
				break;
			}

			// 通过x,y决定传送到哪个地图哪个传送口附近
			MmochatMap curMap = MmochatMapService.getMapByMapId(me.getMapId());

			// 将本队人马传到新地图新坐标
			MmochatMapService.tranToNewMap(curMap, me.getLine(), newMap, me
					.getLine(), targetX, targetY, members);
			log
					.debug("玩家" + me.getName() + "(skyid=" + me.getSkyId()
							+ ")完成传送");
			return null;

		}
		case 参加个人争霸赛: {
			// 30级:1线; 40级:2线; ..., 110级:9线; 120级:10线
			// 武道会的战斗系统由MmochatScheduleJobService触发实现
			Date now = new Date();
			if (me.getLevel() < 30) {
				return MmochatUtil
						.msgbox(req.getHallState(), "30级以上才能参加个人争霸赛!");
			}
			if ((now.getDay() != 0 && now.getDay() != 3)
					|| now.getHours() != 19 || now.getMinutes() < 40) {
				return MmochatUtil.msgbox(req.getHallState(),
						"个人争霸赛入场时间:每周三、周日19:40-20:00,现在不是入场时间!");
			}
			// level->line, 30,40,50,60,70,80,90,100,110,120
			// TODO:与StartPkGame中的level_line_map要一致
			int[] level_line_map = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
			int levelRange = me.getLevel() / 10 * 10;
			int teamIndex = me.getLevel() / 10 - 3;
			if (teamIndex < 0 || teamIndex >= level_line_map.length) {
				return MmochatUtil.msgbox(req.getHallState(), "没有该等级段的比赛!");
			}
			int lineNeed = level_line_map[teamIndex];
			if (me.getLine() != lineNeed) {
				return MmochatUtil.msgbox(req.getHallState(), levelRange
						+ "级别段的比赛在" + (lineNeed + 1) + "线举行!");
			}
			// 进入比武场
			int targetMapId = MmochatConstant.mapId_30级个人赛 + teamIndex;
			MmochatMap newMap = MmochatMapService.getMapByMapId(targetMapId);
			if (newMap == null) {
				return MmochatUtil.msgbox(req.getHallState(), "会场尚未准备好,请稍候再来!");
			}

			// 地图传送目的地
			int targetX = 235, targetY = 290;
			if (me.getMapId() == targetMapId) {
				log.debug("玩家" + me.getName() + "(skyid=" + me.getSkyId()
						+ ")已经在mapId=" + me.getMapId() + "的地图了!,无需传送");
				break;
			}
			if (me.isInBattle()) {
				log.debug("玩家" + me.getName() + "(skyid=" + me.getSkyId()
						+ ")已进入战斗,无法传送");
				break;
			}
			List<MmochatPlayer> members = new ArrayList<MmochatPlayer>();
			if (me.isInTeam()) {
				return MmochatUtil.msgbox(req.getHallState(), "不能组队入场!");
			} else {
				members.add(me);
			}
			if (members.size() <= 0) {
				log.debug("玩家" + me.getName() + "(skyid=" + me.getSkyId()
						+ ")传送人数为0，无法传送;");
				break;
			}

			// 通过x,y决定传送到哪个地图哪个传送口附近
			MmochatMap curMap = MmochatMapService.getMapByMapId(me.getMapId());

			// 将本队人马传到新地图新坐标
			MmochatMapService.tranToNewMap(curMap, me.getLine(), newMap, me
					.getLine(), targetX, targetY, members);
			log
					.debug("玩家" + me.getName() + "(skyid=" + me.getSkyId()
							+ ")完成传送");
			return null;

		}
		case 历届出类拔萃者: {
			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinType(WinType.List);
			tlv.setLeftName("查看");
			tlv.setRightName("返回");
			tlv.setTitle("历届出类拔萃");
			tlv.setWinHeight(228);
			tlv.addRightTLV(new CloseWinTLV());

			for (int level = 120; level >= 30; level -= 10) {
				String item = level + "级出类拔萃";
				tlv.addItemEvent(item, new ClearDataTLV(), new AddDataTLV(
						(int) level));
			}
			tlv.addLeftTLV(new SendDataTLV(MmochatConstant.getClientModuleId(),
					MmochatMain.getModuleInstID(),
					MmochatConstant.MSGCODE_MMOCHAT_C_9_26, (int) req
							.getRoleId()));
			tlv.addLeftTLV(new ShowWaitingMsgBoxTLV());
			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		case 申请进入跨服擂台: {
			if (me.getLevel() < 30) {
				return MmochatUtil.msgbox(req.getHallState(), "30级以上才能进入跨服擂台!");
			}
			if (me.isInBattle()) {
				log.debug("玩家" + me.getName() + "(skyid=" + me.getSkyId()
						+ ")已进入战斗,无法传送");
				break;
			}
			if (me.isInTeam()) {
				return MmochatUtil.msgbox(req.getHallState(), "不能组队进入!");
			}

			// 请求进入跨服战服务器(得到允许后，离开本服)
			Integer serverId = MmochatMain.getThisServerId();
			if (serverId == null) {
				return MmochatUtil.msgbox(req.getHallState(),
						"服务器尚未准备好，请过5分钟再试!");
			}

			// 跨服竞技点要足够多
			if (me.getPk_score() < MmochatConstant.pkScoreNeedToEnter) {
				return MmochatUtil.msgbox(req.getHallState(), "您当前只有"
						+ me.getPk_score() + "点跨服竞技点," + "竞技点至少"
						+ MmochatConstant.pkScoreNeedToEnter + "点才能入场。当竞技点低于"
						+ MmochatConstant.onlinePkScoreLimit + "点时，在线每分钟增加"
						+ MmochatConstant.addPkScorePerUnit + "点竞技点。");
			}

			synchronized (multiServerPkNpcLock) {
				Mmochat_EnterMultiServerLeiTai pack = new Mmochat_EnterMultiServerLeiTai(
						MmochatMain.pkServerInstID);
				pack.setSkyId(me.getSkyId());
				pack.setRoleId(me.getRoleId());
				pack.setSrcInstId(MmochatMain.moduleInstID);
				pack.setSrcServerId(serverId);
				pack.setName(me.getName());
				pack.setLevel(me.getLevel());
				pack.setFamily(me.getFamily());
				pack.setConn(req.getUserConnInfo());

				// 申请进入跨服战服务器
				MmochatUtil.sendMultiServerPack(pack);

				// 控制入场频率
				try {
					Thread.sleep(100);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
			return null;
		}
		case 跨服竞技点说明: {
			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinType(WinType.Text);
			tlv.setRightName("返回");
			tlv.setTitle(type.toString());
			tlv.setWinHeight(188);
			tlv.addRightTLV(new CloseWinTLV());
			String content = "";
			content += MmochatUtil.wrapColor("您的竞技点:" + me.getPk_score()
					+ "点\n\n", Color.yellow);
			content += MmochatUtil.wrapColor("[获得途径]\n", Color.green);
			content += "当竞技点低于" + MmochatConstant.onlinePkScoreLimit
					+ "点时，在线每分钟将增加" + MmochatConstant.addPkScorePerUnit
					+ "点!\n\n";
			content += MmochatUtil.wrapColor("[使用功能]\n", Color.green);
			content += "进入跨服擂台要求竞技点至少" + MmochatConstant.pkScoreNeedToEnter
					+ "点!在跨服擂台，战斗获胜将赢得竞技点，失败则扣除竞技点。竞技点可以兑换各种称号奖励等。";

			tlv.setContent(new Text(content));

			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		case 查询我的竞技点: {
			return MmochatUtil.msgbox(req.getHallState(), "您当前竞技点数为:"
					+ me.getPk_score() + "点!");
		}
		case 竞技点输赢规则: {
			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinType(WinType.Text);
			tlv.setRightName("返回");
			tlv.setTitle(type.toString());
			tlv.setWinHeight(188);
			tlv.addRightTLV(new CloseWinTLV());
			String content = "";
			content += "1、队伍成员的等级越高，则系统认为队伍实力越强。\n";
			content += "2、实力强的队伍战败，会扣除更多的竞技点；实力强的队伍获胜，得到的竞技点也会减少。\n";
			content += "3、战败时，所有队员扣除相同的竞技点。\n";
			content += "4、获胜时，得到的竞技点，由所有队伍成员平分。\n";
			content += "5、实力相同的2支队伍比武时，失败方全体扣除的总的竞技点数＝30*人数较少一方队伍人数";

			tlv.setContent(new Text(content));

			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		case 在线玩家竞技榜: {
			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinType(WinType.List);
			tlv.setLeftName("兑换");
			tlv.setRightName("返回");
			tlv.setTitle("在线玩家竞技榜");
			tlv.setWinHeight(228);
			tlv.addRightTLV(new CloseWinTLV());

			List<MmochatPlayer> list = new ArrayList<MmochatPlayer>(
					MmochatMainService.players.values());
			Collections.sort(list);
			int index = list.indexOf(me);
			int count = 0;
			tlv.addItemEvent(MmochatUtil.wrapColor("我的排名:" + (index + 1),
					Color.magenta));
			for (MmochatPlayer r : list) {
				count++;
				String item = MmochatUtil.wrapColor("No." + count + " "
						+ r.getName(), Color.yellow);
				item += "\n竞技点:" + r.getPk_score();
				item += "\n" + r.getLevel() + "级," + r.getCurChenHaoInfo();
				tlv.addItemEvent(item);

				if (count >= 20) {
					break;
				}
			}
			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		case 竞技点兑换称号: {
			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinType(WinType.List);
			tlv.setLeftName("兑换");
			tlv.setRightName("返回");
			tlv.setTitle("兑换称号");
			tlv.setWinHeight(228);
			tlv.addRightTLV(new CloseWinTLV());

			String item;
			MmochatChenHaoType chenHaoType;

			{
				chenHaoType = MmochatChenHaoType.擂台新贵;
				item = MmochatUtil.wrapColor(chenHaoType.toString(),
						Color.yellow)
						+ "\n";
				item += "价格:1000竞技点\n";
				item += "效果:所有属性+1。限时7天。";
				tlv.addItemEvent(item, new ClearDataTLV(), new AddDataTLV(
						(int) chenHaoType.getKey()));
			}

			{
				chenHaoType = MmochatChenHaoType.擂台高手;
				item = MmochatUtil.wrapColor(chenHaoType.toString(),
						Color.yellow)
						+ "\n";
				item += "价格:3000竞技点\n";
				item += "效果:所有属性+3。限时7天。";
				tlv.addItemEvent(item, new ClearDataTLV(), new AddDataTLV(
						(int) chenHaoType.getKey()));
			}

			{
				chenHaoType = MmochatChenHaoType.擂台狂人;
				item = MmochatUtil.wrapColor(chenHaoType.toString(),
						Color.yellow)
						+ "\n";
				item += "价格:6000竞技点\n";
				item += "效果:所有属性+6。限时7天。";
				tlv.addItemEvent(item, new ClearDataTLV(), new AddDataTLV(
						(int) chenHaoType.getKey()));
			}

			{
				chenHaoType = MmochatChenHaoType.擂台小神;
				item = MmochatUtil.wrapColor(chenHaoType.toString(),
						Color.yellow)
						+ "\n";
				item += "价格:10000竞技点\n";
				item += "效果:所有天赋+1、所有属性+6。限时7天。";
				tlv.addItemEvent(item, new ClearDataTLV(), new AddDataTLV(
						(int) chenHaoType.getKey()));
			}

			{
				chenHaoType = MmochatChenHaoType.擂台武神;
				item = MmochatUtil.wrapColor(chenHaoType.toString(),
						Color.yellow)
						+ "\n";
				item += "价格:15000竞技点\n";
				item += "效果:所有天赋+1、所有属性+10。限时7天。";
				tlv.addItemEvent(item, new ClearDataTLV(), new AddDataTLV(
						(int) chenHaoType.getKey()));
			}

			{
				chenHaoType = MmochatChenHaoType.擂台战神;
				item = MmochatUtil.wrapColor(chenHaoType.toString(),
						Color.yellow)
						+ "\n";
				item += "价格:30000竞技点\n";
				item += "效果:所有天赋+2、所有属性+15。限时7天。";
				tlv.addItemEvent(item, new ClearDataTLV(), new AddDataTLV(
						(int) chenHaoType.getKey()));
			}

			tlv.addLeftTLV(new SendDataTLV(MmochatConstant.getClientModuleId(),
					MmochatMain.getModuleInstID(),
					MmochatConstant.MSGCODE_MMOCHAT_C_9_54, (int) req
							.getRoleId()));
			tlv.addLeftTLV(new ShowWaitingMsgBoxTLV());
			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		case 进入跨服武道会场: {
			if (me.getLevel() < 30) {
				return MmochatUtil.msgbox(req.getHallState(),
						"30级以上才能参加跨服武道会比赛!");
			}
			if (me.isInBattle()) {
				log.debug("玩家" + me.getName() + "(skyid=" + me.getSkyId()
						+ ")已进入战斗,无法传送");
				break;
			}
			if (me.isInTeam()) {
				return MmochatUtil.msgbox(req.getHallState(), "不能组队进入!");
			}

			// 请求进入跨服战服务器(得到允许后，离开本服)
			Integer serverId = MmochatMain.getThisServerId();
			if (serverId == null) {
				return MmochatUtil.msgbox(req.getHallState(),
						"服务器尚未准备好，请过5分钟再试!");
			}

			// 试道王者称号，或是有“武神光环”效果的人才有资格进入
			boolean hasQualification = false;
			if (me.hasChenHaoType(MmochatChenHaoType.试道王者)) {
				hasQualification = true;
			} else if (me.hasPropEffect(MmochatPropType.武神光环.getEffectKey())) {
				hasQualification = true;
			}
			if (!hasQualification) {
				return MmochatUtil.msgbox(req.getHallState(), "只有具备"
						+ MmochatUtil.wrapColor("试道王者", Color.yellow)
						+ "称号，或身上有"
						+ MmochatUtil.wrapColor("武神光环", Color.yellow)
						+ "效果的玩家，才有资格参加跨服武道大会!您两者都不具备，无法参加。");
			}
			// Date now = new Date();
			// if (now.getDay() != 4) {
			// return MmochatUtil.msgbox(req.getHallState(),
			// "跨服武道会入场时间:每周四的19:40-20:00,现在不是入场时间!");
			// }

			synchronized (multiServerPkNpcLock) {
				Mmochat_EnterOtherServerMap pack = new Mmochat_EnterOtherServerMap(
						MmochatMain.pkServerInstID);
				pack.setSkyId(me.getSkyId());
				pack.setRoleId(me.getRoleId());
				pack.setSrcInstId(MmochatMain.moduleInstID);
				pack.setSrcServerId(serverId);
				pack.setName(me.getName());
				pack.setLevel(me.getLevel());
				pack.setFamily(me.getFamily());
				pack.setConn(req.getUserConnInfo());

				// 申请进入跨服战服务器
				MmochatUtil.sendMultiServerPack(pack);

				// 控制入场频率
				try {
					Thread.sleep(100);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
			return null;
		}
		case 进入武道会场: {
			// 30-129级每10级一个阶段
			// 每周一20点-22点开放, 19:40-20:00入场
			// 30级:1线; 40级:2线; ..., 110级:9线; 120级:10线
			// 武道会的战斗系统由MmochatScheduleJobService触发实现
			Date now = new Date();
			if (me.getLevel() < 30) {
				return MmochatUtil
						.msgbox(req.getHallState(), "30级以上才能参加武道会比赛!");
			}
			if ((now.getDay() != 1) || now.getHours() != 19
					|| now.getMinutes() < 40) {
				return MmochatUtil.msgbox(req.getHallState(),
						"武道会入场时间:每周一的19:40-20:00,现在不是入场时间!");
			}
			if (now.getDay() == 4) {
				return MmochatUtil.msgbox(req.getHallState(),
						"武道会入场时间:每周一的19:40-20:00,现在不是入场时间!原周四的武道会已改为跨服武道大会。");
			}
			// level->line, 30,40,50,60,70,80,90,100,110,120
			// TODO:与StartPkGame中的level_line_map要一致
			int[] level_line_map = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
			int levelRange = me.getLevel() / 10 * 10;
			int teamIndex = me.getLevel() / 10 - 3;
			if (teamIndex < 0 || teamIndex >= level_line_map.length) {
				return MmochatUtil.msgbox(req.getHallState(), "没有该等级段的比赛!");
			}
			int lineNeed = level_line_map[teamIndex];
			if (me.getLine() != lineNeed) {
				return MmochatUtil.msgbox(req.getHallState(), levelRange
						+ "级别段的比赛在" + (lineNeed + 1) + "线举行!");
			}
			// 进入比武场
			int targetMapId = MmochatConstant.mapId_30级武道会 + teamIndex;
			MmochatMap newMap = MmochatMapService.getMapByMapId(targetMapId);
			if (newMap == null) {
				return MmochatUtil.msgbox(req.getHallState(), "会场尚未准备好,请稍候再来!");
			}

			// 地图传送目的地
			int targetX = 235, targetY = 290;
			if (me.getMapId() == targetMapId) {
				log.debug("玩家" + me.getName() + "(skyid=" + me.getSkyId()
						+ ")已经在mapId=" + me.getMapId() + "的地图了!,无需传送");
				break;
			}
			if (me.isInBattle()) {
				log.debug("玩家" + me.getName() + "(skyid=" + me.getSkyId()
						+ ")已进入战斗,无法传送");
				break;
			}
			List<MmochatPlayer> members = new ArrayList<MmochatPlayer>();
			if (me.isInTeam()) {
				MmochatTeam team = MmochatTeamService.teams.get(me.getTeamId());
				if (team == null) {
					me.leaveTeam();
					members.add(me);
				} else {
					if (!team.isTeamLeader(me.getRoleId())) {
						log.debug("玩家" + me.getName() + "(skyid="
								+ me.getSkyId() + ")在队伍中，且不为队长，无法传送;");
						return MmochatUtil.msgbox(req.getHallState(),
								"您在队伍中，请和队长一起行动!");
					}
					for (Integer roleId : team.getMemberId().values()) {
						MmochatPlayer member = MmochatMainService.players
								.get(roleId);
						if (member != null) {
							members.add(member);
						}
					}
				}
			} else {
				members.add(me);
			}
			if (members.size() <= 0) {
				log.debug("玩家" + me.getName() + "(skyid=" + me.getSkyId()
						+ ")传送人数为0，无法传送;");
				break;
			}
			for (MmochatPlayer player : members) {
				if (player.getLevel() < levelRange
						|| player.getLevel() > levelRange + 9) {
					return MmochatUtil.msgbox(req.getHallState(), player
							.getName()
							+ "与您不是一个等级段,无法一同进入!");
				}
			}
			// 通过x,y决定传送到哪个地图哪个传送口附近
			MmochatMap curMap = MmochatMapService.getMapByMapId(me.getMapId());

			// 将本队人马传到新地图新坐标
			MmochatMapService.tranToNewMap(curMap, me.getLine(), newMap, me
					.getLine(), targetX, targetY, members);
			log
					.debug("玩家" + me.getName() + "(skyid=" + me.getSkyId()
							+ ")完成传送");
			return null;
		}
		case 历届试道王者: {
			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinType(WinType.List);
			tlv.setLeftName("查看");
			tlv.setRightName("返回");
			tlv.setTitle("历届试道王者");
			tlv.setWinHeight(228);
			tlv.addRightTLV(new CloseWinTLV());

			for (int level = 120; level >= 30; level -= 10) {
				String item = level + "级试道王者";
				tlv.addItemEvent(item, new ClearDataTLV(), new AddDataTLV(
						(int) level));
			}
			tlv.addLeftTLV(new SendDataTLV(MmochatConstant.getClientModuleId(),
					MmochatMain.getModuleInstID(),
					MmochatConstant.MSGCODE_MMOCHAT_C_9_24, (int) req
							.getRoleId()));
			tlv.addLeftTLV(new ShowWaitingMsgBoxTLV());
			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		case 试道王者宣言: {
			// 判定是否为试道王者
			boolean hasChenhao = false;
			for (MmochatChenHao chenhao : me.getChenHaoMap().values()) {
				if (chenhao.getType() == MmochatChenHaoType.试道王者
						&& !chenhao.isTimeOut()) {
					hasChenhao = true;
					break;
				}
			}
			if (!hasChenhao) {
				return MmochatUtil.msgbox(req.getHallState(),
						"只有拥有试道王者称号的玩家，才能设置试道王者宣言!");
			}
			// 判定日期
			Date now = new Date();
			if (now.getDay() == 1 || now.getDay() == 2) {
				// 周一周二可以设置
				String msg = MmochatUtil.wrapColor(
						"试道王者宣言将出现在登陆公告中，同等级段所有玩家会看到此宣言!\n", Color.magenta)
						+ "请设置您的宣言!";
				CreateEditBoxTLV edit = new CreateEditBoxTLV();
				edit.setTitle(msg);
				edit.setLeftName("设置");
				edit.setRightName("取消");
				edit.setContentLenMax(20);
				edit.setBoxType(CreateEditBoxTLV.TYPE_MSGBOX);
				edit.setInputType(CreateEditBoxTLV.INPUT_ANY << 4);
				edit.addLeftTLV(new ClearDataTLV());
				edit.addLeftTLV(new AddEditBoxTLV());
				edit.addLeftTLV(new SendDataTLV(MmochatConstant
						.getClientModuleId(), MmochatMain.getModuleInstID(),
						MmochatConstant.MSGCODE_MMOCHAT_C_9_66, (int) me
								.getRoleId()));
				ShowWaitingMsgBoxTLV wait = new ShowWaitingMsgBoxTLV();
				wait.setShowCancel(false);
				edit.addLeftTLV(wait);

				return MmochatUtil.tlvResponse(req.getHallState(), edit);
			} else {
				return MmochatUtil
						.msgbox(req.getHallState(), "只有周一、周二才允许设置宣言。");
			}
		}
		case 跨服王者宣言: {

			// 判定是否为试道王者
			boolean hasChenhao = false;
			for (MmochatChenHao chenhao : me.getChenHaoMap().values()) {
				if (chenhao.getType() == MmochatChenHaoType.跨服王者
						&& !chenhao.isTimeOut()) {
					hasChenhao = true;
					break;
				}
			}
			if (!hasChenhao) {
				return MmochatUtil.msgbox(req.getHallState(),
						"只有拥有跨服王者称号的玩家，才能设置跨服王者宣言!");
			}
			// 判定日期
			Date now = new Date();
			if (now.getDay() == 4 || now.getDay() == 5) {
				// 周四周五可以设置
				String msg = MmochatUtil.wrapColor("跨服王者宣言将出现在"
						+ MmochatUtil.wrapColor("所有区服", Color.yellow)
						+ "的登陆公告中，同等级段所有玩家会看到此宣言!\n", Color.magenta)
						+ "请设置您的宣言!";
				CreateEditBoxTLV edit = new CreateEditBoxTLV();
				edit.setTitle(msg);
				edit.setLeftName("设置");
				edit.setRightName("取消");
				edit.setContentLenMax(20);
				edit.setBoxType(CreateEditBoxTLV.TYPE_MSGBOX);
				edit.setInputType(CreateEditBoxTLV.INPUT_ANY << 4);
				edit.addLeftTLV(new ClearDataTLV());
				edit.addLeftTLV(new AddEditBoxTLV());
				edit.addLeftTLV(new SendDataTLV(MmochatConstant
						.getClientModuleId(), MmochatMain.getModuleInstID(),
						MmochatConstant.MSGCODE_MMOCHAT_C_9_65, (int) me
								.getRoleId()));
				ShowWaitingMsgBoxTLV wait = new ShowWaitingMsgBoxTLV();
				wait.setShowCancel(false);
				edit.addLeftTLV(wait);

				return MmochatUtil.tlvResponse(req.getHallState(), edit);
			} else {
				return MmochatUtil.msgbox(req.getHallState(),
						"只有周四、周五才允许设置跨服宣言。");
			}
		}
		case 历届跨服试道王者: {
			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinType(WinType.List);
			tlv.setLeftName("查看");
			tlv.setRightName("返回");
			tlv.setTitle("跨服试道王者");
			tlv.setWinHeight(228);
			tlv.addRightTLV(new CloseWinTLV());

			for (int level = 120; level >= 30; level -= 10) {
				String item = level + "级跨服道王";
				tlv.addItemEvent(item, new ClearDataTLV(), new AddDataTLV(
						(int) level));
			}
			tlv.addLeftTLV(new SendDataTLV(MmochatConstant.getClientModuleId(),
					MmochatMain.getModuleInstID(),
					MmochatConstant.MSGCODE_MMOCHAT_C_9_32, (int) req
							.getRoleId()));
			tlv.addLeftTLV(new ShowWaitingMsgBoxTLV());
			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		case 进入我的帮派: {
			if (!me.hasGang()) {
				return MmochatUtil.msgbox(req.getHallState(), "您还没有加入帮派!");
			}
			MmochatGang myGang = MmochatGangService.getGangById(me.getGangId());
			if (myGang == null) {
				// 此帮派已经不存在，将此人的帮派信息置为无帮派
				try {
					MmochatDao.setNoGang(me);
					me.setNoGang();
					return MmochatUtil.msgbox(req.getHallState(), "您的帮派已经解散!");
				} catch (Exception e) {
					e.printStackTrace();
					return MmochatUtil
							.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
				}
			} else {
				// 读取帮派地图
				MmochatMap newMap = MmochatGangService.getGangMap(myGang);
				if (newMap == null) {
					return MmochatUtil.msgbox(req.getHallState(), "没有找到您的帮派!");
				}
				// 进入帮派地图
				// 地图传送目的地
				int targetX = 185, targetY = 120;
				int targetMapId = newMap.getMapId();
				if (me.getMapId() == targetMapId) {
					log.debug("玩家" + me.getName() + "(skyid=" + me.getSkyId()
							+ ")已经在mapId=" + me.getMapId() + "的地图了!,无需传送");
					break;
				}
				if (me.isInBattle()) {
					log.debug("玩家" + me.getName() + "(skyid=" + me.getSkyId()
							+ ")已进入战斗,无法传送");
					break;
				}
				List<MmochatPlayer> members = new ArrayList<MmochatPlayer>();
				if (me.isInTeam()) {
					MmochatTeam team = MmochatTeamService.teams.get(me
							.getTeamId());
					if (team == null) {
						me.leaveTeam();
						members.add(me);
					} else {
						if (!team.isTeamLeader(me.getRoleId())) {
							log.debug("玩家" + me.getName() + "(skyid="
									+ me.getSkyId() + ")在队伍中，且不为队长，无法传送;");
							return MmochatUtil.msgbox(req.getHallState(),
									"您在队伍中，请和队长一起行动!");
						}
						for (Integer roleId : team.getMemberId().values()) {
							MmochatPlayer member = MmochatMainService.players
									.get(roleId);
							if (member != null) {
								members.add(member);
							}
						}
					}
				} else {
					members.add(me);
				}
				if (members.size() <= 0) {
					log.debug("玩家" + me.getName() + "(skyid=" + me.getSkyId()
							+ ")传送人数为0，无法传送;");
					break;
				}
				for (MmochatPlayer player : members) {
					if (player.getGangId() != me.getGangId()) {
						return MmochatUtil.msgbox(req.getHallState(), player
								.getName()
								+ "不是本帮成员，无法进入!");
					}
				}
				MmochatMap curMap = MmochatMapService.getMapByMapId(me
						.getMapId());

				// 将本队人马传到新地图新坐标
				MmochatMapService.tranToNewMap(curMap, me.getLine(), newMap, me
						.getLine(), targetX, targetY, members);
				log.debug("玩家" + me.getName() + "(skyid=" + me.getSkyId()
						+ ")完成传送");
			}
			break;
		}
		case 查看所有帮派: {
			Mmochat_15_12S pack = new Mmochat_15_12S();
			pack.setHallState(req.getHallState());
			pack.setCurPage(0);
			pack.setGangList(MmochatGangService.getAllGang());
			return pack;
		}
		case 创建帮派: {
			if (me.hasGang()) {
				return MmochatUtil.msgbox(req.getHallState(),
						"您已经有帮派了，请先退出当前帮派!");
			}
			if (me.getLevel() < MmochatConstant.minLevelNeedToCreateGang) {
				return MmochatUtil.msgbox(req.getHallState(), "创建帮派需要人物达到"
						+ MmochatConstant.minLevelNeedToCreateGang + "级以上。");
			}
			// TODO:其它创建条件

			// 创建
			CreateEditBoxTLV edit = new CreateEditBoxTLV();
			edit.setTitle("创建帮派需要"
					+ MmochatUtil
							.getColorMoney(MmochatConstant.moneyForCreatGang)
					+ "文,请输入要创建的帮派名,1-6字!");
			edit.setLeftName("创建");
			edit.setRightName("取消");
			edit.setContentLenMax(6);
			edit.setBoxType(CreateEditBoxTLV.TYPE_MSGBOX);
			edit.setInputType(CreateEditBoxTLV.INPUT_ANY << 4);
			edit.addLeftTLV(new ClearDataTLV());
			edit.addLeftTLV(new AddDataTLV((int) me.getRoleId()));
			edit.addLeftTLV(new AddEditBoxTLV());
			edit.addLeftTLV(new SendDataTLV(
					MmochatConstant.getClientModuleId(), MmochatMain
							.getModuleInstID(),
					MmochatConstant.MSGCODE_MMOCHAT_C_15_1, null));
			ShowWaitingMsgBoxTLV wait = new ShowWaitingMsgBoxTLV();
			wait.setShowCancel(false);
			edit.addLeftTLV(wait);

			return MmochatUtil.tlvResponse(req.getHallState(), edit);
		}
		case 退出帮派: {
			if (!me.hasGang()) {
				return MmochatUtil.msgbox(req.getHallState(), "您尚未加入帮派!");
			}
			MmochatGang myGang = MmochatGangService.getGangById(me.getGangId());
			if (myGang == null) {
				return MmochatUtil.msgbox(req.getHallState(), "您尚未加入帮派!");
			}
			MmochatGangMember myInfo = myGang.getMembers().get(me.getRoleId());
			if (myInfo == null) {
				return MmochatUtil.msgbox(req.getHallState(), "您尚未加入帮派!");
			}
			if (myInfo.getType() == MmochatGangMemberType.帮主) {
				if (myGang.getMembers().size() > 1) {
					return MmochatUtil.msgbox(req.getHallState(),
							"您的帮派尚有其它成员，作为帮主，您不能就此退出帮派。如果您坚持要退出，"
									+ "您可以将帮主之位传给其它成员，或者当帮内没有其它成员时方可退出。");
				}
			}
			String hint = "您确定退出"
					+ MmochatUtil.wrapColor(myGang.getName(), Color.green)
					+ "么?";
			CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
			msgbox.setContent(new Text(hint));
			msgbox.setLeftName("退出");
			msgbox.setRightName("取消");
			msgbox.addLeftTLV(new ClearDataTLV());
			msgbox.addLeftTLV(new SendDataTLV(MmochatConstant
					.getClientModuleId(), MmochatMain.getModuleInstID(),
					MmochatConstant.MSGCODE_MMOCHAT_C_15_11, (int) me
							.getRoleId()));
			ShowWaitingMsgBoxTLV wait = new ShowWaitingMsgBoxTLV();
			wait.setShowCancel(false);
			msgbox.addLeftTLV(wait);
			return MmochatUtil.tlvResponse(req.getHallState(), msgbox);
		}
		case 为帮派出力: {
			if (!me.hasGang()) {
				return MmochatUtil.msgbox(req.getHallState(), "您尚未加入帮派!");
			}
			MmochatGang myGang = MmochatGangService.getGangById(me.getGangId());
			if (myGang == null) {
				return MmochatUtil.msgbox(req.getHallState(), "您尚未加入帮派!");
			}
			MmochatTask myTask = me.getTaskByType(MmochatTaskType.帮派任务);
			while (myTask != null
					&& (myTask.getTaskState() == MmochatTaskStateType.未接 || myTask
							.getTaskState() == MmochatTaskStateType.已完成)) {
				me.getTasks().remove(myTask.getTaskId());
				myTask = me.getTaskByType(MmochatTaskType.帮派任务);
			}
			if (myTask != null
					&& (myTask.getTaskState() == MmochatTaskStateType.已接 || myTask
							.getTaskState() == MmochatTaskStateType.待完成)) {
				if (myTask.getFinish_npcId() == npc.getNpcId()
						&& me.canFinishTask(myTask.getTaskId())) {
					// 已完成,可交付
					if (myTask.getFinish_talk().size() == 0) {
						// 没有对话则直接完成任务
						// 交任务对话结束，是否需要进行NPC战斗
						if (myTask.needBattleBeforeFinish()) {
							// 玩家队伍
							List<MmochatPlayer> myTeam = new ArrayList<MmochatPlayer>();
							if (me.isInTeam()) {
								MmochatTeam team = MmochatTeamService.teams
										.get(me.getTeamId());
								if (team == null) {
									me.leaveTeam();
									myTeam.add(me);
								} else {
									for (Integer roleId : team.getMemberId()
											.values()) {
										MmochatPlayer member = MmochatMainService
												.getRoleFromBuffer(roleId);
										if (member != null) {
											myTeam.add(member);
										}
									}
								}
							} else {
								myTeam.add(me);
							}

							// 进入任务NPC战斗
							if (npc instanceof MmochatTempNpc) {
								MmochatTempNpc boss = (MmochatTempNpc) npc;
								synchronized (boss) {
									if (boss.getState() == MmochatNpcState.空闲) {
										boss.setState(MmochatNpcState.战斗中);
									} else if (boss.getState() == MmochatNpcState.离开) {
										return MmochatUtil.msgbox(req
												.getHallState(), "怪物已经离开!");
									} else if (boss.getState() == MmochatNpcState.战斗中) {
										return MmochatUtil.msgbox(req
												.getHallState(),
												"怪物正在战斗中,请稍候再来!");
									}
								}
							}
							MmochatBattleService.enterNpcPk(me.getMapId(),
									(byte) me.getLine(), myTeam,
									me.getRoleId(), myTask, req.getNpcId());
							return null;
						} else {
							MmochatTaskService.dealFinishingTask(me, myTask);
							return MmochatUtil.msgbox(req.getHallState(),
									"任务完成!");
						}
					} else {
						CreateMsgBoxTLVWithBmp msgbox = MmochatTaskService
								.getTaskFinishTalkMsg(me, myTask, req
										.getRoleId(), myTask.getTaskId(), req
										.getNpcId());
						return MmochatUtil.tlvResponse(req.getHallState(),
								new CloseWinTLV(
										MmochatConstant.TLV_WIN_TASKLIST),
								msgbox);
					}
				}
				return MmochatUtil.msgbox(req.getHallState(),
						"您已经领取了一个帮派任务,请先完成再来领取新任务吧!");
			}
			if (me.isInTeam()) {
				return MmochatUtil.msgbox(req.getHallState(), "组队状态下不能领取任务!");
			}
			if (System.currentTimeMillis() - me.getLastTimeOfCancelGangTask() < MmochatConstant.intervalOfGangTask) {
				return MmochatUtil.msgbox(req.getHallState(),
						"您刚刚放弃了一个任务或者您刚登陆游戏未满1分钟，请休息一会再来吧!");
			}

			List<MmochatTask> taskList = new ArrayList<MmochatTask>();
			for (MmochatTask task : MmochatTaskService.tasks.values()) {
				if (task.getTaskType() == MmochatTaskType.帮派任务) {
					if (task.getAccept_npcId() == MmochatConstant.npcId_gangNpc2_inFile) {
						if (task.canAccept(me)) {
							taskList.add(task);
						}
					}
				}
			}
			if (taskList.size() == 0) {
				return MmochatUtil.msgbox(req.getHallState(), "暂时没有适合您的任务!");
			}
			int index = MmochatUtil.getRandomValue(taskList.size());
			MmochatTask task = taskList.get(index);
			MmochatTask newTask = task.getClone();
			if (task.getAccept_npcId() == MmochatConstant.npcId_gangNpc2_inFile) {
				newTask.setAccept_npcId(npc.getNpcId());
			}
			if (task.getFinish_npcId() == MmochatConstant.npcId_gangNpc2_inFile) {
				newTask.setFinish_npcId(npc.getNpcId());
			}
			me.addTask(newTask);
			if (newTask.getAccept_talk().size() == 0) {
				// 没有对话则直接接受任务
				newTask.setTaskState(MmochatTaskStateType.已接);
				CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
				msgbox.setLeftName("确定");
				try {
					MmochatDao.updateRoleTasks(me);
				} catch (Exception e) {
					e.printStackTrace();
					msgbox.setContent(new Text("服务器忙,任务接受失败!"));
					return MmochatUtil.tlvResponse(req.getHallState(),
							new CloseWinTLV(MmochatConstant.TLV_WIN_TASKLIST),
							msgbox);
				}
				msgbox.setContent(new Text("任务接受成功!"));
				// 下发增加任务
				Mmochat_4_11S pack = new Mmochat_4_11S();
				pack.setActionType(0);
				pack.setMe(me);
				pack.setTask(newTask);
				MmochatUtil.sendCommonPack(me, pack);

				// Mmochat_4_8S pack = new Mmochat_4_8S();
				// pack.setHintKey(newTask.getHintKey());
				// pack.setHintWord(newTask.getHintWord());
				// MmochatUtil.sendCommonPack(me, pack);
				return MmochatUtil.tlvResponse(req.getHallState(),
						new CloseWinTLV(MmochatConstant.TLV_WIN_TASKLIST),
						msgbox);
			} else {
				CreateMsgBoxTLVWithBmp msgbox = MmochatTaskService
						.getTaskAcceptTalkMsg(me, newTask, req.getRoleId(),
								newTask.getTaskId(), req.getNpcId());
				return MmochatUtil.tlvResponse(req.getHallState(),
						new CloseWinTLV(MmochatConstant.TLV_WIN_TASKLIST),
						msgbox);
			}
		}
		case 更换帮派任务: {
			if (!me.hasGang()) {
				return MmochatUtil.msgbox(req.getHallState(), "您尚未加入帮派!");
			}
			MmochatGang myGang = MmochatGangService.getGangById(me.getGangId());
			if (myGang == null) {
				return MmochatUtil.msgbox(req.getHallState(), "您尚未加入帮派!");
			}
			MmochatTask myTask = me
					.getUnFinishedTaskByType(MmochatTaskType.帮派任务);
			if (myTask != null
					&& (myTask.getTaskState() == MmochatTaskStateType.已接 || myTask
							.getTaskState() == MmochatTaskStateType.待完成)) {
				String msg = "更换帮派任务需要消耗"
						+ MmochatUtil
								.getColorMoney(MmochatConstant.moneyNeedToChangeGangTask)
						+ "文钱!您确定要更换么?";
				msg = MmochatUtil.wrapColor(msg, Color.yellow);
				CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
				msgbox.setContent(new Text(msg));
				msgbox.setLeftName("确定");
				msgbox.setRightName("取消");
				msgbox.addLeftTLV(new ClearDataTLV());
				msgbox.addLeftTLV(new AddDataTLV((int) req.getNpcId()));
				msgbox.addLeftTLV(new SendDataTLV(MmochatConstant
						.getClientModuleId(), MmochatMain.getModuleInstID(),
						MmochatConstant.MSGCODE_MMOCHAT_C_9_50, (int) me
								.getRoleId()));
				msgbox.addLeftTLV(new ShowWaitingMsgBoxTLV());
				return MmochatUtil.tlvResponse(req.getHallState(), msgbox);
			} else {
				return MmochatUtil.msgbox(req.getHallState(), "您身上没有帮派任务!");
			}
		}
		case 放弃任务: {
			// 放弃帮派任务
			if (!me.hasGang()) {
				return MmochatUtil.msgbox(req.getHallState(), "您尚未加入帮派!");
			}
			MmochatGang myGang = MmochatGangService.getGangById(me.getGangId());
			if (myGang == null) {
				return MmochatUtil.msgbox(req.getHallState(), "您尚未加入帮派!");
			}
			MmochatTask myTask = me
					.getUnFinishedTaskByType(MmochatTaskType.帮派任务);
			if (myTask != null
					&& (myTask.getTaskState() == MmochatTaskStateType.已接 || myTask
							.getTaskState() == MmochatTaskStateType.待完成)) {
				me.getTasks().remove(myTask.getTaskId());
				// 下发删除任务
				Mmochat_4_12S pack = new Mmochat_4_12S();
				pack.setTaskId(myTask.getTaskId());
				MmochatUtil.sendCommonPack(me, pack);

				Integer nextTaskId = myTask.getNext_taskId();
				while (nextTaskId != null) {
					MmochatTask task = me.getTaskById(nextTaskId);
					if (task == null) {
						break;
					}
					me.getTasks().remove(nextTaskId);
					// 下发删除任务
					Mmochat_4_12S pack1 = new Mmochat_4_12S();
					pack1.setTaskId(nextTaskId);
					MmochatUtil.sendCommonPack(me, pack1);

					nextTaskId = task.getNext_taskId();
				}
				Integer nextAccept_taskId = myTask.getNextAccept_taskId();
				while (nextAccept_taskId != null) {
					MmochatTask task = me.getTaskById(nextAccept_taskId);
					if (task == null) {
						break;
					}
					me.getTasks().remove(nextAccept_taskId);
					// 下发删除任务
					Mmochat_4_12S pack1 = new Mmochat_4_12S();
					pack1.setTaskId(nextAccept_taskId);
					MmochatUtil.sendCommonPack(me, pack1);

					nextAccept_taskId = task.getNextAccept_taskId();
				}

				try {
					MmochatDao.updateRoleTasks(me);
				} catch (Exception e) {
					e.printStackTrace();
					return MmochatUtil
							.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
				}
				me.setLastTimeOfCancelGangTask(System.currentTimeMillis());
				return MmochatUtil.msgbox(req.getHallState(), "任务已取消!");
			} else {
				return MmochatUtil.msgbox(req.getHallState(), "您身上没有帮派任务!");
			}
		}
		case 参加帮派大乱斗: {
			String msg;
			msg = "帮派大乱斗每周二、周五在" + (MmochatGangMixedPkGame.pkLine + 1)
					+ "线举办一次。19:40到20:00为进场时间，20:00到22:00为比赛时间。"
					+ "每人初始体力1000，体力为0时将被请出赛场。当场内只剩一个帮派或时间耗光时比赛结束，"
					+ "比赛结果按帮派积分由高到低进行排名。是否进入赛场?";
			CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
			msgbox.setContent(new Text(msg));
			msgbox.setLeftName("进入");
			msgbox.setRightName("取消");
			msgbox.addLeftTLV(new ClearDataTLV());
			msgbox.addLeftTLV(new SendDataTLV(MmochatConstant
					.getClientModuleId(), MmochatMain.getModuleInstID(),
					MmochatConstant.MSGCODE_MMOCHAT_C_15_15, (int) me
							.getRoleId()));
			return MmochatUtil.tlvResponse(req.getHallState(), msgbox);
		}
		case 历届帮战前十: {
			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinType(WinType.List);
			tlv.setLeftName("查看");
			tlv.setRightName("返回");
			tlv.setTitle("历届帮战前十");
			tlv.setWinHeight(228);
			tlv.addRightTLV(new CloseWinTLV());

			SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
			for (MmochatEventLog eventLog : eventLogList) {
				if (eventLog.getType() == MmochatEventType.帮派大乱斗) {
					String item = fmt.format(new Date(eventLog.getTime()));
					tlv.addItemEvent(item, new ClearDataTLV(), new AddDataTLV(
							(int) eventLog.getId()));
				}
			}
			tlv.addLeftTLV(new SendDataTLV(MmochatConstant.getClientModuleId(),
					MmochatMain.getModuleInstID(),
					MmochatConstant.MSGCODE_MMOCHAT_C_9_27, (int) req
							.getRoleId()));
			tlv.addLeftTLV(new ShowWaitingMsgBoxTLV());
			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		case 获取帮派称谓: {
			if (!me.hasGang()) {
				return MmochatUtil.msgbox(req.getHallState(), "您还没有加入帮派!");
			}
			MmochatGang gang = MmochatGangService.getGangById(me.getGangId());
			if (gang == null) {
				return MmochatUtil.msgbox(req.getHallState(), "您还没有加入帮派!");
			}
			MmochatGangMember member = gang.getMembers().get(me.getRoleId());
			if (member == null) {
				return MmochatUtil.msgbox(req.getHallState(), "您还没有加入帮派!");
			}
			MmochatChenHaoType[] chenhaoList = MmochatChenHaoType
					.getGangChenhaoList();
			for (MmochatChenHaoType chenhaoType : chenhaoList) {
				if (me.getChenHaoMap().containsKey(chenhaoType)) {
					return MmochatUtil.msgbox(req.getHallState(), "您已经有帮派称谓了!");
				}
			}
			switch (member.getType()) {
			case 帮众: {
				MmochatChenHao chenhao = new MmochatChenHao();
				chenhao.setType(MmochatChenHaoType.帮众);
				chenhao.setExtraEffectInfo("同气连枝:与同帮派玩家组队时，防御增加同帮人数*1%");
				chenhao.setName(gang.getName() + " "
						+ MmochatChenHaoType.帮众.toString());
				MmochatChenHao.addAndUpdateChenHaoAndSaveSql(me.getRoleId(),
						chenhao);
				break;
			}
			case 精英: {
				MmochatChenHao chenhao = new MmochatChenHao();
				chenhao.setType(MmochatChenHaoType.精英);
				chenhao.setExtraEffectInfo("同气连枝:与同帮派玩家组队时，防御增加同帮人数*2%");
				chenhao.setName(gang.getName() + " "
						+ MmochatChenHaoType.精英.toString());
				MmochatChenHao.addAndUpdateChenHaoAndSaveSql(me.getRoleId(),
						chenhao);
				break;
			}
			case 副帮: {
				MmochatChenHao chenhao = new MmochatChenHao();
				chenhao.setType(MmochatChenHaoType.副帮主);
				chenhao.setExtraEffectInfo("同气连枝:与同帮派玩家组队时，防御增加同帮人数*2%");
				chenhao.setName(gang.getName() + " "
						+ MmochatChenHaoType.副帮主.toString());
				MmochatChenHao.addAndUpdateChenHaoAndSaveSql(me.getRoleId(),
						chenhao);
				break;
			}
			case 帮主: {
				MmochatChenHao chenhao = new MmochatChenHao();
				chenhao.setType(MmochatChenHaoType.帮主);
				chenhao.setExtraEffectInfo("同气连枝:与同帮派玩家组队时，防御增加同帮人数*2%");
				chenhao.setName(gang.getName() + " "
						+ MmochatChenHaoType.帮主.toString());
				MmochatChenHao.addAndUpdateChenHaoAndSaveSql(me.getRoleId(),
						chenhao);
				break;
			}
			default:
				break;
			}
			return MmochatUtil.msgbox(req.getHallState(), "您获得了帮派称谓!");
		}
		case 学习帮派技能: {
			if (!me.hasGang()) {
				return MmochatUtil.msgbox(req.getHallState(), "您还没有加入帮派!");
			}
			MmochatGang gang = MmochatGangService.getGangById(me.getGangId());
			if (gang == null) {
				return MmochatUtil.msgbox(req.getHallState(), "您还没有加入帮派!");
			}

			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinType(WinType.List);
			tlv.setLeftName("学习");
			tlv.setRightName("返回");
			tlv.setTitle("帮派技能");
			tlv.setWinHeight(208);
			tlv.addRightTLV(new CloseWinTLV());

			for (MmochatGangSkillType skillType : MmochatGangSkillType.values()) {
				MmochatGangSkill skill = gang.getSkills().get(skillType);
				int skillLevel = 0;
				if (skill != null) {
					skillLevel = skill.getLevel();
				}
				String item = skillType.toString() + "(" + skillLevel + "级)";
				tlv.addItemEvent(item, new ClearDataTLV(), new AddDataTLV(
						(int) skillType.getValue()));
			}
			tlv.addLeftTLV(new SendDataTLV(MmochatConstant.getClientModuleId(),
					MmochatMain.getModuleInstID(),
					MmochatConstant.MSGCODE_MMOCHAT_C_15_19, (int) req
							.getRoleId()));
			tlv.addLeftTLV(new ShowWaitingMsgBoxTLV());
			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		case 帮派升级: {
			if (!me.hasGang()) {
				return MmochatUtil.msgbox(req.getHallState(), "您还没有加入帮派!");
			}
			MmochatGang gang = MmochatGangService.getGangById(me.getGangId());
			if (gang == null) {
				return MmochatUtil.msgbox(req.getHallState(), "您还没有加入帮派!");
			}
			MmochatGangMember member = gang.getMembers().get(me.getRoleId());
			if (member == null) {
				return MmochatUtil.msgbox(req.getHallState(), "您还没有加入帮派!");
			}
			if (member.getType() != MmochatGangMemberType.帮主) {
				return MmochatUtil
						.msgbox(req.getHallState(), "此等大事还是交由帮主来决定吧!");
			}
			MmochatGangLevelType gangLevel = gang.getLevel();
			MmochatGangLevelType maxLevel = MmochatGangLevelType
					.getMaxLevelType();
			if (gangLevel.getValue() == maxLevel.getValue()) {
				return MmochatUtil.msgbox(req.getHallState(),
						"本帮已经升至最高级别帮派,无法再升级!");
			}
			MmochatGangLevelType nextLevel = MmochatGangLevelType
					.getNextLevelType(gangLevel);
			int needBuild = nextLevel.getBuildNeed();
			if (gang.getBuildValue() < needBuild) {
				return MmochatUtil.msgbox(req.getHallState(), "升级至"
						+ nextLevel.toString() + "帮派,要求帮派建设度达到"
						+ MmochatUtil.wrapColor(needBuild + "", Color.yellow)
						+ ",本帮建设度尚未达标。");
			}

			// TODO：其它条件
			String msg = "您确定要将帮派升至" + nextLevel.toString() + "帮派么?";
			CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
			msgbox.setContent(new Text(msg));
			msgbox.setLeftName("升级");
			msgbox.setRightName("取消");
			msgbox.addLeftTLV(new ClearDataTLV());
			msgbox.addLeftTLV(new SendDataTLV(MmochatConstant
					.getClientModuleId(), MmochatMain.getModuleInstID(),
					MmochatConstant.MSGCODE_MMOCHAT_C_15_21, (int) me
							.getRoleId()));
			return MmochatUtil.tlvResponse(req.getHallState(), msgbox);
		}
		case 提取帮派资金: {
			if (!me.hasGang()) {
				return MmochatUtil.msgbox(req.getHallState(), "您还没有加入帮派!");
			}
			MmochatGang gang = MmochatGangService.getGangById(me.getGangId());
			if (gang == null) {
				return MmochatUtil.msgbox(req.getHallState(), "您还没有加入帮派!");
			}
			MmochatGangMember member = gang.getMembers().get(me.getRoleId());
			if (member == null) {
				return MmochatUtil.msgbox(req.getHallState(), "您还没有加入帮派!");
			}
			if (member.getType() != MmochatGangMemberType.帮主) {
				return MmochatUtil.msgbox(req.getHallState(), "帮派资金只能由帮主来管理!");
			}

			String msg = "当前帮派资金剩余"
					+ MmochatUtil.getColorMoney(gang.getMoney())
					+ "文钱!请输入要提取的资金数量。";

			CreateEditBoxTLV edit = new CreateEditBoxTLV();
			edit.setTitle(msg);
			edit.setLeftName("提取");
			edit.setRightName("取消");
			edit.setContentLenMax(8);
			edit.setBoxType(CreateEditBoxTLV.TYPE_MSGBOX);
			edit.setInputType(CreateEditBoxTLV.INPUT_ANY << 4);
			edit.addLeftTLV(new ClearDataTLV());
			edit.addLeftTLV(new AddDataTLV((int) me.getRoleId()));
			edit.addLeftTLV(new AddEditBoxTLV());
			edit.addLeftTLV(new SendDataTLV(
					MmochatConstant.getClientModuleId(), MmochatMain
							.getModuleInstID(),
					MmochatConstant.MSGCODE_MMOCHAT_C_15_23, null));
			ShowWaitingMsgBoxTLV wait = new ShowWaitingMsgBoxTLV();
			wait.setShowCancel(false);
			edit.addLeftTLV(wait);

			return MmochatUtil.tlvResponse(req.getHallState(), edit);
		}
		case 创建战队: {
			if (me.hasPkTeam()) {
				return MmochatUtil.msgbox(req.getHallState(),
						"您已经有自己的战队了，请按8键查看!");
			}
			// 创建
			CreateEditBoxTLV edit = new CreateEditBoxTLV();
			edit.setTitle("请输入要创建的战队名,3-8字!");
			edit.setLeftName("创建");
			edit.setRightName("取消");
			edit.setContentLenMax(8);
			edit.setBoxType(CreateEditBoxTLV.TYPE_MSGBOX);
			edit.setInputType(CreateEditBoxTLV.INPUT_ANY << 4);
			edit.addLeftTLV(new ClearDataTLV());
			edit.addLeftTLV(new AddDataTLV((int) me.getRoleId()));
			edit.addLeftTLV(new AddEditBoxTLV());
			edit.addLeftTLV(new SendDataTLV(
					MmochatConstant.getClientModuleId(), MmochatMain
							.getModuleInstID(),
					MmochatConstant.MSGCODE_MMOCHAT_C_16_1, null));
			ShowWaitingMsgBoxTLV wait = new ShowWaitingMsgBoxTLV();
			wait.setShowCancel(false);
			edit.addLeftTLV(wait);

			return MmochatUtil.tlvResponse(req.getHallState(), edit);
		}
		case 我要收徒弟: {
			if (me.getLevel() < MmochatConstant.minLevelOfTeacher) {
				return MmochatUtil.msgbox(req.getHallState(),
						MmochatConstant.minLevelOfTeacher + "级以上才能收徒弟!");
			}
			if (me.isStudentFull()) {
				return MmochatUtil.msgbox(req.getHallState(), "你已经有"
						+ me.getStudents().size() + "个徒弟了，够你忙的了!");
			}
			if (!me.isInTeam()) {
				return MmochatUtil.msgbox(req.getHallState(),
						"请和对方一起组队来我这里!只能两人组队噢。");
			}
			if (MmochatTeamService.getTeamState(me) != MmochatTeamStateType.队长) {
				return MmochatUtil.msgbox(req.getHallState(),
						"请和对方一起组队来我这里!只能两人组队噢。");
			}
			MmochatTeam team = MmochatTeamService.teams.get(me.getTeamId());
			if (team == null) {
				me.leaveTeam();
				return MmochatUtil.msgbox(req.getHallState(),
						"请和对方一起组队来我这里!只能两人组队噢。");
			}
			if (team.getMemberId().size() != 2) {
				return MmochatUtil.msgbox(req.getHallState(),
						"请组上你要收的徒弟，只能两人组队噢，不要组上无关人员。");
			}
			MmochatPlayer he = null;
			for (Integer roleId : team.getMemberId().values()) {
				if (roleId != me.getRoleId()) {
					he = MmochatMainService.players.get(roleId);
					break;
				}
			}
			if (he == null) {
				return MmochatUtil.msgbox(req.getHallState(), "对方已掉线，请稍后再来!");
			}
			if (he.hasTeacher()) {
				return MmochatUtil.msgbox(req.getHallState(), "对方已经有师傅了!");
			}
			if (he.getLevel() > MmochatConstant.maxLevelOfStudent) {
				return MmochatUtil.msgbox(req.getHallState(),
						"对方已经有自立能力，不需要师傅了!");
			}

			String msg = "你确定要收"
					+ MmochatUtil.wrapColor(he.getName(), Color.green)
					+ "为徒弟么?";
			CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
			msgbox.setContent(new Text(msg));
			msgbox.setLeftName("确定");
			msgbox.setRightName("取消");
			msgbox.addLeftTLV(new ClearDataTLV());
			msgbox.addLeftTLV(new AddDataTLV((int) he.getRoleId()));
			msgbox
					.addLeftTLV(new SendDataTLV(MmochatConstant
							.getClientModuleId(),
							MmochatMain.getModuleInstID(),
							MmochatConstant.MSGCODE_MMOCHAT_C_9_7, (int) me
									.getRoleId()));
			return MmochatUtil.tlvResponseWithoutHallState(msgbox);
		}
		case 我要出师: {
			if (!me.hasTeacher()) {
				return MmochatUtil.msgbox(req.getHallState(), "您还没有拜师!");
			}
			if (me.getLevel() < MmochatConstant.graduateLevel) {
				return MmochatUtil.msgbox(req.getHallState(),
						MmochatConstant.graduateLevel + "级才能出师!");
			}
			// 徒弟抽1件80等级装备,抽1个300元宝以下人民币道具
			if (!me.hasEnoughPackageSpace(2)) {
				return MmochatUtil.msgbox(req.getHallState(),
						"请先整理出至少2个包裹空位,以免奖品掉落!");
			}
			Map<Integer, MmochatPackageGrid> packageBak = (Map<Integer, MmochatPackageGrid>) MmochatUtil
					.deepClone(me.getMyPackage(),
							new TypeToken<Map<Integer, MmochatPackageGrid>>() {
							}.getType());
			String awardMsg = "";
			MmochatEquip equip = MmochatEquipService.getRandEquip(80, 89, 0, 0,
					100);
			me.addObjectToPackage(equip);
			awardMsg += "您获得了一件"
					+ MmochatUtil.wrapColor(equip.getName(), equip.getQuality()
							.getColor());

			MmochatPropType[] propList = null;
			propList = new MmochatPropType[] { MmochatPropType.锦囊,
					MmochatPropType.喇叭, MmochatPropType.成长丹,
					MmochatPropType.超级成长丹, MmochatPropType.轮回水,
					MmochatPropType.防冻剂, MmochatPropType.镇定剂,
					MmochatPropType.虚无水, MmochatPropType.迟滞水,
					MmochatPropType.八卦令, MmochatPropType.银联卡,
					MmochatPropType.赎罪牌, MmochatPropType.后悔药,
					MmochatPropType.混沌石, MmochatPropType.急急如律令,
					MmochatPropType.天尊令, MmochatPropType.道尊令,
					MmochatPropType.驱兽令, MmochatPropType.驭兽令,
					MmochatPropType.龙涎香, MmochatPropType.小血池,
					MmochatPropType.小法池, MmochatPropType.中法池,
					MmochatPropType.大法池, MmochatPropType.小血玲珑,
					MmochatPropType.小法玲珑, MmochatPropType.中法玲珑,
					MmochatPropType.大法玲珑 };
			int index = MmochatUtil.getRandomValue(propList.length);
			MmochatPropType type1 = propList[index];
			MmochatProp prop = new MmochatProp(type1);
			prop.setCanDeal(false);
			boolean success = me.addObjectToPackage(prop);
			if (!success) {
				MmochatChatService.sendSystemMsgToPerson(me,
						"您的道具包裹已满，无法获得道具奖励。");
			} else {
				awardMsg += "," + type1.toString() + "。";
			}

			// 出师
			MmochatPlayer he = MmochatMainService.getRoleFromBuffer(me
					.getTeacher_roleId());
			if (he == null) {
				try {
					he = MmochatDao.getRole(me.getTeacher_roleId());
				} catch (EmptyResultDataAccessException e) {
					// 师傅可能已删号
					int teacherRoleId = me.getTeacher_roleId();
					String teacherName = me.getTeacher_name();
					me.setNoTeacher();
					try {
						MmochatDao.gradute(me);
					} catch (Exception e1) {
						e1.printStackTrace();
						me.setTeacher(teacherRoleId, teacherName);
						me.setMyPackage(packageBak);
						return MmochatUtil.msgbox(req.getHallState(),
								"服务器忙,请稍候再试!");
					}
					return MmochatUtil.msgbox(req.getHallState(), "恭喜，您已经出师了。"
							+ awardMsg);
				} catch (Exception e) {
					e.printStackTrace();
					return MmochatUtil
							.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
				}
			}
			if (he == null) {
				// 师傅可能已删号
				int teacherRoleId = me.getTeacher_roleId();
				String teacherName = me.getTeacher_name();
				me.setNoTeacher();
				try {
					MmochatDao.gradute(me);
				} catch (Exception e) {
					e.printStackTrace();
					me.setTeacher(teacherRoleId, teacherName);
					me.setMyPackage(packageBak);
					return MmochatUtil
							.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
				}
				return MmochatUtil.msgbox(req.getHallState(), "恭喜，您已经出师了。"
						+ awardMsg);
			}

			// 脱离师傅
			me.setNoTeacher();
			he.delStudent((Integer) me.getRoleId());
			try {
				MmochatDao.gradute(me, he);
			} catch (Exception e) {
				e.printStackTrace();
				me.setTeacher(he.getRoleId(), he.getName());
				he.addStudent(me);
				me.setMyPackage(packageBak);
				return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
			}

			return MmochatUtil.msgbox(req.getHallState(), "恭喜，您已经出师了。"
					+ awardMsg);
		}
		case 领取师傅工资: {
			Date now = new Date();
			if (now.getDate() > 5) {
				return MmochatUtil.msgbox(req.getHallState(), "每月1号到5号，师德值"
						+ MmochatConstant.teacherScorePerGame
						+ "以上的师傅可以到我这里来领取工资，师德越高，奖励越丰厚噢，但今天不是发工资时间。");
			}
			if (me.getTeacherScore() < MmochatConstant.teacherScorePerGame) {
				return MmochatUtil.msgbox(req.getHallState(), "师德值"
						+ MmochatConstant.teacherScorePerGame
						+ "以上的师傅才可以到我这里来领取工资,您的师德值不足,带徒弟打怪就能获得师德值噢。");
			}
			if (!me.hasEnoughPackageSpace(6)) {
				return MmochatUtil.msgbox(req.getHallState(),
						"请先整理出至少6个包裹空位,以免奖品掉落!");
			}
			Map<Integer, MmochatPackageGrid> packageBak = (Map<Integer, MmochatPackageGrid>) MmochatUtil
					.deepClone(me.getMyPackage(),
							new TypeToken<Map<Integer, MmochatPackageGrid>>() {
							}.getType());

			int propNum = 0;
			if (me.getTeacherScore() < MmochatConstant.teacherScorePerGame + 2000) {
				propNum = 4;
			} else if (me.getTeacherScore() < MmochatConstant.teacherScorePerGame + 4000) {
				propNum = 5;
			} else {
				propNum = 6;
			}

			MmochatPropType[] propList = null;
			propList = new MmochatPropType[] { MmochatPropType.锦囊,
					MmochatPropType.喇叭, MmochatPropType.成长丹,
					MmochatPropType.超级成长丹, MmochatPropType.轮回水,
					MmochatPropType.防冻剂, MmochatPropType.镇定剂,
					MmochatPropType.虚无水, MmochatPropType.迟滞水,
					MmochatPropType.八卦令, MmochatPropType.银联卡,
					MmochatPropType.赎罪牌, MmochatPropType.后悔药,
					MmochatPropType.混沌石, MmochatPropType.急急如律令,
					MmochatPropType.天尊令, MmochatPropType.道尊令,
					MmochatPropType.驱兽令, MmochatPropType.驭兽令,
					MmochatPropType.龙涎香, MmochatPropType.小血池,
					MmochatPropType.小法池, MmochatPropType.中法池,
					MmochatPropType.大法池, MmochatPropType.小血玲珑,
					MmochatPropType.小法玲珑, MmochatPropType.中法玲珑,
					MmochatPropType.大法玲珑 };
			String awardMsg = "";
			for (int i = 0; i < propNum; i++) {
				int index = MmochatUtil.getRandomValue(propList.length);
				MmochatPropType type1 = propList[index];
				MmochatProp prop = new MmochatProp(type1);
				boolean success = me.addObjectToPackage(prop);
				if (!success) {
					MmochatChatService.sendSystemMsgToPerson(me,
							"您的道具包裹已满，无法获得道具奖励。");
				} else {
					awardMsg += type1.toString() + ",";
				}
			}

			int teachScore = me.getTeacherScore();
			me.setTeacherScore(0);
			try {
				MmochatDao.getTeacherSalary(me);
			} catch (Exception e) {
				e.printStackTrace();
				me.setTeacherScore(teachScore);
				me.setMyPackage(packageBak);
				return MmochatUtil.msgbox(req.getHallState(), "服务器忙，请稍候再试!");
			}
			return MmochatUtil.msgbox(req.getHallState(), "您获得了"
					+ MmochatUtil.wrapColor(awardMsg, Color.yellow)
					+ "您的师德值已清0!请继续努力。");
		}
		case 我要踢除徒弟: {
			if (me.getStudents().size() == 0) {
				return MmochatUtil.msgbox(req.getHallState(), "您还没有徒弟!");
			}

			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinType(WinType.List);
			tlv.setLeftName("踢除");
			tlv.setRightName("返回");
			tlv.setTitle("我的徒弟");
			tlv.setWinHeight(208);
			tlv.setWinId(MmochatConstant.TLV_WIN_STUDENTLIST);
			tlv
					.addRightTLV(new CloseWinTLV(
							MmochatConstant.TLV_WIN_STUDENTLIST));

			for (Entry<Integer, String> entry : me.getStudents().entrySet()) {
				int roleId = entry.getKey();
				String name = entry.getValue();
				tlv.addItemEvent(name, new ClearDataTLV(), new AddDataTLV(
						(int) roleId));
			}

			CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
			msgbox.setContent(new Text("您确定要将此人逐出师门么?"));
			msgbox.setLeftName("确定");
			msgbox.setRightName("取消");
			msgbox.addLeftTLV(new SendDataTLV(MmochatConstant
					.getClientModuleId(), MmochatMain.getModuleInstID(),
					MmochatConstant.MSGCODE_MMOCHAT_C_9_10, (int) me
							.getRoleId()));
			ShowWaitingMsgBoxTLV wait = new ShowWaitingMsgBoxTLV();
			wait.setShowCancel(false);
			msgbox.addLeftTLV(wait);
			tlv.addLeftTLV(msgbox);
			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		case 我要离开师门: {
			if (!me.hasTeacher()) {
				return MmochatUtil.msgbox(req.getHallState(), "您还没有师傅!");
			}
			String msg = "你确定要离开师傅么?";
			CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
			msgbox.setContent(new Text(msg));
			msgbox.setLeftName("确定");
			msgbox.setRightName("取消");
			msgbox.addLeftTLV(new ClearDataTLV());
			msgbox
					.addLeftTLV(new SendDataTLV(MmochatConstant
							.getClientModuleId(),
							MmochatMain.getModuleInstID(),
							MmochatConstant.MSGCODE_MMOCHAT_C_9_9, (int) me
									.getRoleId()));
			return MmochatUtil.tlvResponse(req.getHallState(), msgbox);
		}
		case 师德值说明: {
			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinType(WinType.Text);
			tlv.setRightName("返回");
			tlv.setTitle(type.toString());
			tlv.setWinHeight(188);
			tlv.addRightTLV(new CloseWinTLV());
			String content = "";
			content += "师德值是对师傅功德的奖励。领取师傅工资时需要消耗师德值。";
			content += MmochatUtil.wrapColor("\n当师傅带领徒弟在野外打怪，并且徒弟等级与怪的等级"
					+ "相差10级以内时，师傅就能获得一定的师德值。", Color.green);
			content += MmochatUtil.wrapColor(
					"\n每场野外战斗胜利后，队伍中每个0-49级徒弟会贡献2点师德值，"
							+ "50-64级的徒弟会贡献3点师德值，65-74级的徒弟会贡献4点师德值。"
							+ "75级以上的徒弟不会贡献师德值。", Color.yellow);
			tlv.setContent(new Text(content));

			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		case 宠物赛跑金钱场: {
			MmochatBet bet = MmochatBetService.bets.get(MmochatBetType.游戏币赌场);
			if (bet == null) {
				return MmochatUtil.msgbox(req.getHallState(), "暂未开放!");
			}
			// 加入到赌盘玩家列表
			bet.getPlayersInBet().put(me.getRoleId(), me.getRoleId());
			// 下发17.5协议
			Mmochat_17_5S pack = new Mmochat_17_5S();
			pack.setBet(bet);
			pack.setMe(me);
			pack.setOpenWin(true);
			String msg = "系统:欢迎进入宠物赛跑金钱场!\n";
			msg += bet.getBetSystemMsg();
			pack.setSystemMsg(msg);

			return pack;
		}
		case 宠物赛跑元宝场: {
			MmochatBet bet = MmochatBetService.bets.get(MmochatBetType.元宝赌场);
			if (bet == null) {
				return MmochatUtil.msgbox(req.getHallState(), "暂未开放!");
			}
			// 加入到赌盘玩家列表
			bet.getPlayersInBet().put(me.getRoleId(), me.getRoleId());
			// 下发17.5协议
			Mmochat_17_5S pack = new Mmochat_17_5S();
			pack.setBet(bet);
			pack.setMe(me);
			pack.setOpenWin(true);
			String msg = "系统:欢迎进入宠物赛跑元宝场!\n";
			msg += bet.getBetSystemMsg();
			pack.setSystemMsg(msg);

			return pack;
		}
		case 官方攻略: {
			String content = "";
			content += MmochatUtil.wrapColor("概要\n", Color.yellow);
			content += "1、基本玩法\n";
			content += "2、法则揭密\n";
			content += "3、其它说明\n\n";
			content += MmochatUtil.wrapColor("详述\n", Color.yellow);
			content += MmochatUtil.wrapColor("1、基本玩法\n", Color.green);
			content += "枯树精、长尾、仙姑、雪妖四宠物进行跑步比赛，猜中谁跑第一就能赢得相应奖励。"
					+ "比赛每隔一定时间举办一场。\n";
			content += MmochatUtil.wrapColor("什么是赔率\n", Color.yellow);
			content += "赔率就是奖励的倍数，如您押注1000文钱，赔率2.5倍，则您猜中后获得2500文钱。"
					+ "扣除押注的1000文钱，净赢1500文钱。\n";
			content += MmochatUtil.wrapColor("如何取消下注\n", Color.yellow);
			content += "在下注期间，如果您下错了注，只要对此宠物再次下注，金额设为0即可。";
			content += MmochatUtil.wrapColor("如何成功下注\n", Color.yellow);
			content += "下注后可以离开休闲坊进行其它活动。但如果比赛开始时，"
					+ "您已经下线，或身上的金钱或元宝不足以支付下注金额时则此次下注自动取消。\n\n";
			content += MmochatUtil.wrapColor("2、法则揭密\n", Color.green);
			content += "宠物赛跑是以概率学为理论依据的。" + "简单的说，就是赔率越高，中的概率越低；赔率越低，中的概率越高。\n";
			content += "具体计算方式：中的概率＝90/赔率。比如雪妖赔率是9倍，那么出雪妖的概率=90/9＝10，"
					+ "也就是10%的可能性雪妖会赢。这个意思就是平均1000场9倍，有100场会中。\n\n";
			content += MmochatUtil.wrapColor("3、其它说明\n", Color.green);
			content += "宠物赛跑结果只和赔率有关，这在第2点已经详细说明。与各方压注总额及其它因素都无关。"
					+ "另外由于赔率只能精确到小数点后1位，所以4个宠物的概率之和加起来可能与100%有极小的出入，"
					+ "但实际计算时是刚好100%。";

			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinType(WinType.Text);
			tlv.setRightName("返回");
			tlv.setTitle("官方攻略");
			tlv.setWinHeight(188);
			tlv.addRightTLV(new CloseWinTLV());
			tlv.setContent(new Text(content));

			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		default:
			break;
		}
		return null;
	}

	public static void cleanTimeOutFuBenForRole(MmochatPlayer me) {
		if (me == null) {
			return;
		}
		if (me.isInFuBenActivity()) {
			MmochatFuBen fuBen = fuBens.get(me.getFuBenId());
			if (fuBen == null) {
				me.leaveFuBen();
			} else {
				if (!fuBen.getOwners().contains(me.getRoleId())) {
					// 可能是重启服务器后，虽然fuBenId存在，但为不同的副本
					me.leaveFuBen();
				}
			}
		}
	}

	public static void cleanTimeOutGangFuBen(MmochatGang gang) {
		if (gang == null) {
			return;
		}
		if (gang.isInFuBenActivity()) {
			MmochatGangFuBen fuBen = gangFuBens.get(gang.getFuBenId());
			if (fuBen == null) {
				gang.closeFuBen();
			} else {
				if (fuBen.getGangId() != gang.getId()) {
					// 可能是重启服务器后，虽然fuBenId存在，但为不同的副本
					gang.closeFuBen();
				}
			}
		}
	}

	// 9.6游戏帮助
	@SkymobiService
	public SkymobiProtocolMessage handleC_9_6(SkymobiHandler handler,
			Mmochat_9_6C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		String title[] = new String[] { "基本操作", "快捷键", "打怪指南", "角色系统", "宠物系统",
				"好友系统", "技能系统", "装备系统", "交易系统", "组队系统", "任务系统" };
		String content = "暂无资料";
		switch (req.getIndex()) {
		case 0:
			// 基本操作
			content = MmochatUtil.wrapColor("[行走]", Color.yellow);
			content += "\n按方向键或触屏点击空地。\n\n";
			content += MmochatUtil.wrapColor("[对话]", Color.yellow);
			content += "\n靠近NPC后按中间键或触屏点击NPC。\n\n";
			content += MmochatUtil.wrapColor("[聊天]", Color.yellow);
			content += "\n按1键或触屏点击工具条聊天标志。\n\n";
			content += MmochatUtil.wrapColor("[退出]", Color.yellow);
			content += "\n按右软键或触屏点击工具条第一项<快捷功能>-<退出游戏>。";
			break;
		case 1:
			// 快捷键
			content = MmochatUtil.wrapColor("拨号键:", Color.yellow);
			content += "屏弊部分玩家。长按2秒可屏弊所有玩家。\n";
			content += MmochatUtil.wrapColor("左软键:", Color.yellow);
			content += "快捷功能。集成各种小功能,如换线，自动遇怪等。\n";
			content += MmochatUtil.wrapColor("1键:", Color.yellow);
			content += "聊天。\n";
			content += MmochatUtil.wrapColor("2键:", Color.yellow);
			content += "自动吃药。系统自动查找您包裹中的药品，选取合适的药物补充您和参战宠物的气血和法力。\n";
			content += MmochatUtil.wrapColor("3键:", Color.yellow);
			content += "打开包裹。\n";
			content += MmochatUtil.wrapColor("4键:", Color.yellow);
			content += "查看任务和活动。\n";
			content += MmochatUtil.wrapColor("5键:", Color.yellow);
			content += "打开小地图。\n";
			content += MmochatUtil.wrapColor("6键:", Color.yellow);
			content += "飞回门派。\n";
			content += MmochatUtil.wrapColor("7键:", Color.yellow);
			content += "创建队伍。如果在队伍中，按7键可查看队伍。\n";
			content += MmochatUtil.wrapColor("8键:", Color.yellow);
			content += "帮派功能。\n";
			content += MmochatUtil.wrapColor("9键:", Color.yellow);
			content += "打开商城。\n";
			content += MmochatUtil.wrapColor("#键:", Color.yellow);
			content += "打开我的好友。\n";
			content += MmochatUtil.wrapColor("*键:", Color.yellow);
			content += "查看角色信息。\n";
			content += MmochatUtil.wrapColor("0键:", Color.yellow);
			content += "查看宠物。";
			break;
		case 2:
			// 打怪指南
			content = MmochatUtil.wrapColor("去打和自己等级差十级以上的怪物是没有经验奖励的，"
					+ "所以打怪要选择适合自己的地图。\n\n", Color.green);
			content += MmochatUtil.wrapColor("0-1级:", Color.yellow);
			content += "西郊。走法：在余杭(新手出生地)按5键打开小地图，小地图上找到<西郊>的位置，"
					+ "点击小地图即可自动行走到目的地。\n";
			content += MmochatUtil.wrapColor("2-6级:", Color.yellow);
			content += "东郊。走法：余杭-东郊。\n";
			content += MmochatUtil.wrapColor("7-12级:", Color.yellow);
			content += "北郊。走法：余杭-北郊。\n";
			content += MmochatUtil.wrapColor("13-18级:", Color.yellow);
			content += "远郊。走法：余杭-北郊-远郊。\n";
			content += MmochatUtil.wrapColor("19-24级:", Color.yellow);
			content += "渡口。走法：余杭-北郊-渡口。\n";
			content += MmochatUtil.wrapColor("25-30级:", Color.yellow);
			content += "南郊。走法：余杭-南郊。\n";
			content += MmochatUtil.wrapColor("31-36级:", Color.yellow);
			content += "沼泽。走法：从余杭的车夫(坐标:426,505)传送到江宁，再从江宁出发到沼泽。\n";
			content += MmochatUtil.wrapColor("37-42级:", Color.yellow);
			content += "西海。走法：余杭-西海。\n";
			content += MmochatUtil.wrapColor("43-48级:", Color.yellow);
			content += "九幽。走法：江宁-九幽。\n";
			content += MmochatUtil.wrapColor("49-54级:", Color.yellow);
			content += "岐山。走法：江宁-岐山。\n";
			content += MmochatUtil.wrapColor("55-60级:", Color.yellow);
			content += "灵山。走法：江宁-灵山。\n";
			content += MmochatUtil.wrapColor("61-66级:", Color.yellow);
			content += "冥府。走法：江宁-灵山-冥府。\n";
			content += MmochatUtil.wrapColor("67-72级:", Color.yellow);
			content += "碧湖。走法：江宁-碧湖。\n";
			content += MmochatUtil.wrapColor("73-78级:", Color.yellow);
			content += "东海。走法：江宁-东海。\n";
			content += MmochatUtil.wrapColor("79-84级:", Color.yellow);
			content += "死海。走法：开封-昆仑-死海。\n";
			content += MmochatUtil.wrapColor("85-90级:", Color.yellow);
			content += "心湖。走法：江宁-心湖。\n";
			content += MmochatUtil.wrapColor("91-96级:", Color.yellow);
			content += "天山。走法：从江宁或余杭的车夫传送到开封，再从开封到天山。\n";
			content += MmochatUtil.wrapColor("97-102级:", Color.yellow);
			content += "妖谷。走法：开封-妖谷。\n";
			content += MmochatUtil.wrapColor("103-108级:", Color.yellow);
			content += "海外。走法：开封-妖谷-海外。\n";
			content += MmochatUtil.wrapColor("109-114级:", Color.yellow);
			content += "天外。走法：开封-妖谷-海外-天外。\n";
			content += MmochatUtil.wrapColor("115-120级:", Color.yellow);
			content += "上清。走法：开封-妖谷-海外-上清。";
			break;
		case 3:
			// 角色系统
			content = MmochatUtil.wrapColor("[查看角色]", Color.yellow);
			content += "\n按*键或触屏点击角色头像。\n\n";
			content += MmochatUtil.wrapColor("[基础属性]", Color.yellow);
			content += "\n角色有四大基础属性：力量、灵力、体质、敏捷。角色每升一级，"
					+ "四项基础属性各增加一点，并获得4点可分配属性点。力量影响物伤，"
					+ "灵力影响法伤和法力，体质影响气血和防御，敏捷影响速度。\n\n";
			content += MmochatUtil.wrapColor("[天赋属性]", Color.yellow);
			content += "\n角色有五大天赋属性：野蛮、智慧、活力、坚韧、灵巧。角色每升两级，"
					+ "获得1点可分配天赋。野蛮影响物伤，智慧影响法伤，活力影响气血上限，坚韧影响防御，"
					+ "灵巧影响速度。天赋决定人物发展方向，如野蛮天赋更高的人，每加1点力量增加的物伤也更多，"
					+ "更擅于物理攻击。";
			break;
		case 4:
			// 宠物系统
			content = MmochatUtil.wrapColor("[捕捉宠物]", Color.yellow);
			content += "\n去野外打怪时，对怪物进行捕捉操作，捕捉成功后怪物就会变成您的宠物。"
					+ "您只能捕捉等级比您低的怪物。\n\n";
			content += MmochatUtil.wrapColor("[查看宠物]", Color.yellow);
			content += "\n按0键或触屏点击宠物头像查看宠物。\n\n";
			content += MmochatUtil.wrapColor("[宠物加点]", Color.yellow);
			content += "\n宠物每升一级，获得4点可分配属性点。力量影响物伤，灵力影响法伤和法力，"
					+ "体质影响气血和防御，敏捷影响速度。\n\n";
			content += MmochatUtil.wrapColor("[宠物成长]", Color.yellow);
			content += "\n每种宠物都有自己的成长上限。使用商城里的(超级)轮回丹可改变现有的宠物成长。"
					+ "宠物成长影响宠物的能力。\n1.血量成长越高，每增加一点体力，增加的气血上限越多。"
					+ "\n2.物攻成长越高，每增加一点力量，增加的物伤越多。"
					+ "\n3.法攻成长越高，每增加一点灵力，增加的法伤越多。"
					+ "\n4.速度成长越高，每增加一点敏捷，增加的速度越多。"
					+ "\n5.物防成长越高，每增加一点体质，增加的物防越多。"
					+ "\n6.法防成长越高，每增加一点体质，增加的法防越多。\n\n";
			content += MmochatUtil.wrapColor("[宠物功能]", Color.yellow);
			content += "宠物是您战斗中不可缺少的伙伴。不同类型的宠物有不同的功能，"
					+ "如血量成长高的血宠，抗击打能力强，善于辅助。物攻法攻成长高的攻宠，伤害输出高，善于杀敌。"
					+ "速度成长高的敏宠，对于专修速度的敏人来说，是最好的辅助。\n\n";
			content += MmochatUtil.wrapColor("[宠物补给]", Color.yellow);
			content += "\n按2键或触屏点击宠物头像上的血条可自动为宠物使用包裹中的药品，"
					+ "补给气血和法力。此操作会同时给角色补给气血和法力。";
			break;
		case 5:
			// 好友系统
			content = MmochatUtil.wrapColor("[我的好友]", Color.yellow);
			content += "\n按#键打开好友面板，点击<我的好友>查看。头像亮的表示在线，暗的表示离线。\n\n";
			content += MmochatUtil.wrapColor("[最近联系人]", Color.yellow);
			content += "\n按#键打开好友面板，点击<最近联系人>。"
					+ "一起组过队或私聊过的玩家会自动成为您的最近联系人，方便您认识新朋友。\n\n";
			content += MmochatUtil.wrapColor("[黑名单]", Color.yellow);
			content += "\n按#键打开好友面板，点击<黑名单>。加入黑名单后，您不会再收到此玩家的私聊消息，"
					+ "您在地图上也不会再看到此玩家。以防止他人恶意骚扰您。\n\n";
			content += MmochatUtil.wrapColor("[添加好友]", Color.yellow);
			content += "\n1.地图上点击玩家，在弹出来的功能菜单上选择<加为好友>。\n";
			content += "2.曾经组过队或私聊过的玩家，进入<最近联系人>可加为好友。\n";
			content += "3.全屏聊天界面，点击聊天信息，弹出此信息的发布人的菜单，点击<加为好友>。\n\n";
			content += MmochatUtil.wrapColor("[好友设置]", Color.yellow);
			content += "\n按左软键打开快捷功能，点击<好友设置>。\n"
					+ "1.拒绝陌生人消息。设置后可过滤陌生人私聊消息。\n"
					+ "2.添加好友认证。设置后，对方添加您为好友时，需要经过您的同意。\n"
					+ "3.拒绝加为好友。设置后，他人无法加您为好友。\n\n";
			content += MmochatUtil.wrapColor("[飞到身边]", Color.yellow);
			content += "\n按#键打开好友面板，点击<我的好友>，点击指定好友，"
					+ "在弹出来的功能菜单中选择<飞到身边>即可飞到在线好友的身边。\n\n";
			content += MmochatUtil.wrapColor("[关注好友]", Color.yellow);
			content += "\n按#键打开好友面板，点击<我的好友>，点击指定好友，"
					+ "在弹出来的功能菜单中选择<关注好友>，关注后，"
					+ "此好友上线或下线时，您都将收到系统提示。再次点击<关注好友>，可取消关注。";

			break;
		case 6:
			// 技能系统
			content = MmochatUtil.wrapColor("[技能种类]", Color.yellow);
			content += "\n人物现有三大类技能：法术技能、障碍技能、辅助技能。法术技能可对敌人造成法术伤害，"
					+ "障碍技能能控制敌人的行动，辅助技能可以提升本方人员的能力。三大门派的技能又有所区别：";
			content += "\n1.蜀山：法术技能属雷系法术，障碍技能为封印，辅助技能可提高角色速度。";
			content += "\n2.拜月：法术技能属毒系法术，障碍技能为混乱，辅助技能可提高角色攻击。";
			content += "\n3.昆仑：法术技能属水系法术，障碍技能为冰冻，辅助技能可提高角色防御。\n\n";
			content += MmochatUtil.wrapColor("[技能目标数]\n", Color.yellow);
			content += "每种技能都有几阶子技能，每个子技能的目标数上限有所不同。目标数是使用技能时，能同时"
					+ "受到技能效果的角色数。如目标数为3的法术技能，能同时攻击3个敌人，操作时只需点选其中一个，"
					+ "其它2个目标系统会自动选取。";
			break;
		case 7:
			// 装备系统
			content = MmochatUtil.wrapColor("[装备获得]", Color.yellow);
			content += "\n任务，打怪，BOSS都有可能获得装备奖励。" + "武器店和防具店里还有白色装备出售。\n\n";
			content += MmochatUtil.wrapColor("[装备品质]", Color.yellow);
			content += "\n装备分为白装，蓝装，金装，粉装，绿装五种。";
			content += "\n1.白装:只有基础属性。可掉落。";
			content += "\n2.蓝装:附加1-3条附加属性。可掉落。";
			content += "\n3.金装:附加3-5条附加属性。可掉落。";
			content += "\n4.粉装:使用粉水晶可以将蓝装转变为粉装。只能人工合成。";
			content += "\n5.绿装:使用绿水晶可以将金装转变为绿装。只能人工合成。\n\n";

			content += MmochatUtil.wrapColor("[装备改造]", Color.yellow);
			content += "\nNPC：余杭兵器铺的巧儿\n";
			content += "效果:改造可使装备基础数值提升。白装可直接改造，"
					+ "其它品质的装备需要提交2块改造石或超级改造石。\n\n";

			content += MmochatUtil.wrapColor("[首饰升级]", Color.yellow);
			content += "\nNPC：余杭兵器铺的巧儿\n";
			content += "效果:低级首饰和2块女娲石可以升级为高级首饰，并增加一条附加属性。\n\n";

			content += MmochatUtil.wrapColor("[装备强化]", Color.yellow);
			content += "\nNPC：江宁兵器铺的左芯\n";
			content += "效果:可以提升某条属性的数值。需要提交一块吸附了属性的白水晶。白水晶的属性类型决定了"
					+ "需要提升的属性类型。如提交的白水晶吸附了力量属性，那么强化时会选取力量属性进行强化。"
					+ "如果装备中有多条力量附加属性，则选取数值较低的进行强化。\n\n";

			content += MmochatUtil.wrapColor("[套装制作]", Color.yellow);
			content += "\nNPC：江宁兵器铺的左芯\n";
			content += "流程：属性抽取->装备合成->装备粉化->装备金化->制作套装。"
					+ "每步操作的细节可到左芯那里进行了解。\n";
			content += "类型：套装分野蛮套装、智慧套装、活力套装、坚韧套装和灵巧套装。不同类型的套装生成的套"
					+ "装属性也会不同。\n";
			content += "套装效果：套装有一条明属性和一条暗属性，明属性直接有效，暗属性需要身上装备的头盔、衣服、鞋子和武器"
					+ "为同一类套装时才会生效，并产生强大的套装效果。";

			break;
		case 8:
			// 交易系统
			content = MmochatUtil.wrapColor("[发起交易]", Color.yellow);
			content += "\n触屏点击要交易的角色，或靠近对方后按中间键，选择要交易的玩家。"
					+ "点击后弹出来功能菜单，选择<交易>功能发起交易。\n\n";
			break;
		case 9:
			// 组队系统
			content = MmochatUtil.wrapColor("[创建队伍]", Color.yellow);
			content += "\n按7键。创建成功后，成为队长，角色头上显示队长旗子。\n\n";
			content += MmochatUtil.wrapColor("[加入队伍]", Color.yellow);
			content += "\n触屏点击队长或队员，弹出功能菜单，选择其中的<加入队伍>。待队长同意后，即加入队伍。\n\n";
			content += MmochatUtil.wrapColor("[查看队伍]", Color.yellow);
			content += "\n加入队伍后，按7键即可查看队伍。\n\n";
			content += MmochatUtil.wrapColor("[队长权利]", Color.yellow);
			content += "\n队长可以批准或拒绝玩家的加入，可以踢出队员，转让队长。"
					+ "队伍中只有队长可以走动，所有队员自动跟在队长后面，无法自行走动。\n\n";
			content += MmochatUtil.wrapColor("[组队奖励]", Color.yellow);
			content += "\n组队打怪或刷道，会有奖励加成。队伍人员越多，奖励加成越多。";
			break;
		case 10:
			// 任务系统
			content = MmochatUtil.wrapColor("[查看任务]", Color.yellow);
			content += "\n按4键显示所有已接任务。并可查看可接任务。\n\n";
			content += MmochatUtil.wrapColor("[领取任务]", Color.yellow);
			content += "\n按4键查看可接任务，点击要领取的任务，查看此任务的任务信息。"
					+ "在任务信息面板，按左软键可自动寻路，走到接任务NPC处。"
					+ "到达NPC附近后，按中间键与NPC交谈。\n\n";
			content += MmochatUtil.wrapColor("[交付任务]", Color.yellow);
			content += "\n按4键查看已接任务，点击要交付的任务，查看此任务的任务信息。"
					+ "在任务信息面板，如果任务可交付，则按左软键可自动寻路，走到交任务NPC处。"
					+ "到达NPC附近后，按中间键与NPC交谈。";
			break;
		default:
			content = "暂无资料";
			break;
		}
		CreateTlvWin tlv = new CreateTlvWin();
		tlv.setWinType(WinType.Text);
		tlv.setRightName("返回");
		tlv.setTitle(title[req.getIndex()]);
		tlv.setWinHeight(188);
		tlv.addRightTLV(new CloseWinTLV());
		tlv.setContent(new Text(content));

		return MmochatUtil.tlvResponse(req.getHallState(), tlv);
	}

	// 9.7 收徒弟
	@SkymobiService
	public SkymobiProtocolMessage handleC_9_7(SkymobiHandler handler,
			Mmochat_9_7C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}

		if (me.getLevel() < MmochatConstant.minLevelOfTeacher) {
			return MmochatUtil.msgbox(req.getHallState(),
					MmochatConstant.minLevelOfTeacher + "级以上才能收徒弟!");
		}
		if (me.isStudentFull()) {
			return MmochatUtil.msgbox(req.getHallState(), "你已经有"
					+ me.getStudents().size() + "个徒弟了，够你忙的了!");
		}
		if (!me.isInTeam()) {
			return MmochatUtil.msgbox(req.getHallState(),
					"请和对方一起组队来我这里!只能两人组队噢。");
		}
		if (MmochatTeamService.getTeamState(me) != MmochatTeamStateType.队长) {
			return MmochatUtil.msgbox(req.getHallState(),
					"请和对方一起组队来我这里!只能两人组队噢。");
		}
		MmochatTeam team = MmochatTeamService.teams.get(me.getTeamId());
		if (team == null) {
			me.leaveTeam();
			return MmochatUtil.msgbox(req.getHallState(),
					"请和对方一起组队来我这里!只能两人组队噢。");
		}
		if (team.getMemberId().size() != 2) {
			return MmochatUtil.msgbox(req.getHallState(),
					"请组上你要收的徒弟，只能两人组队噢，不要组上无关人员。");
		}
		MmochatPlayer he = null;
		for (Integer roleId : team.getMemberId().values()) {
			if (roleId != me.getRoleId()) {
				he = MmochatMainService.players.get(roleId);
				break;
			}
		}
		if (he == null) {
			return MmochatUtil.msgbox(req.getHallState(), "对方已掉线，请稍后再来!");
		}

		if (he.getRoleId() != req.getHisRoleId()) {
			return MmochatUtil.msgbox(req.getHallState(),
					"请组上你要收的徒弟，只能两人组队噢，不要组上无关人员。");
		}

		if (he.hasTeacher()) {
			return MmochatUtil.msgbox(req.getHallState(), "对方已经有师傅了!");
		}
		if (he.getLevel() > MmochatConstant.maxLevelOfStudent) {
			return MmochatUtil.msgbox(req.getHallState(), "对方已经有自立能力，不需要师傅了!");
		}

		String msg = MmochatUtil.wrapColor(me.getName(), Color.green)
				+ "希望成为你的师傅，你愿意么?";
		CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
		msgbox.setContent(new Text(msg));
		msgbox.setLeftName("愿意");
		msgbox.setRightName("拒绝");

		msgbox.addLeftTLV(new ClearDataTLV());
		msgbox.addLeftTLV(new AddDataTLV((int) me.getRoleId())); // teacher
		msgbox.addLeftTLV(new AddDataTLV((int) he.getRoleId())); // student
		msgbox.addLeftTLV(new SendDataTLV(MmochatConstant.getClientModuleId(),
				MmochatMain.getModuleInstID(),
				MmochatConstant.MSGCODE_MMOCHAT_C_9_8, (int) 1));

		msgbox.addRightTLV(new ClearDataTLV());
		msgbox.addRightTLV(new AddDataTLV((int) me.getRoleId())); // teacher
		msgbox.addRightTLV(new AddDataTLV((int) he.getRoleId())); // student
		msgbox.addRightTLV(new SendDataTLV(MmochatConstant.getClientModuleId(),
				MmochatMain.getModuleInstID(),
				MmochatConstant.MSGCODE_MMOCHAT_C_9_8, (int) 0));

		CtrlTLVStructureRequest pack = MmochatUtil
				.tlvResponseWithoutHallState(msgbox);
		MmochatUtil.sendCommonPack(he, pack);
		return MmochatUtil
				.msgbox(req.getHallState(), "那我询问下"
						+ MmochatUtil.wrapColor(he.getName(), Color.green)
						+ "的意愿，请稍候。");
	}

	// 9.8 徒弟的意愿
	@SkymobiService
	public SkymobiProtocolMessage handleC_9_8(SkymobiHandler handler,
			Mmochat_9_8C req) {
		MmochatPlayer teacher = MmochatMainService.players.get(req
				.getTeacher_roleId());
		MmochatPlayer student = MmochatMainService.players.get(req
				.getStudent_roleId());
		if (teacher == null) {
			if (student != null) {
				MmochatUtil.sendCommonMsgbox(student, "对方掉线，请下次再来");
			}
		}
		if (student == null) {
			if (teacher != null) {
				MmochatUtil.sendCommonMsgbox(teacher, "对方掉线，请下次再来");
			}
		}
		if (req.getRet() == 1) {
			// 同意
			student.setTeacher(teacher.getRoleId(), teacher.getName());
			teacher.addStudent(student);

			// 保存数据库
			try {
				MmochatDao.updateRoleTeacherAndStudent(teacher, student);
			} catch (Exception e) {
				e.printStackTrace();
				student.setNoTeacher();
				teacher.delStudent(student.getRoleId());

				MmochatUtil.sendCommonMsgbox(teacher, "数据库忙，请稍候再试。");
				MmochatUtil.sendCommonMsgbox(student, "数据库忙，请稍候再试。");
				return null;
			}

			MmochatChenHao chenhao = new MmochatChenHao();
			chenhao.setType(MmochatChenHaoType.徒弟);
			chenhao.setName(teacher.getName() + "的"
					+ chenhao.getType().toString());
			MmochatChenHao.addAndUpdateChenHaoAndSaveSql(student.getRoleId(),
					chenhao);

			MmochatUtil.sendCommonMsgbox(teacher, MmochatUtil.wrapColor(student
					.getName(), Color.green)
					+ "已成为您的徒弟!带徒弟打怪即可获得师德，好好带徒弟吧。");
			MmochatUtil.sendCommonMsgbox(student, MmochatUtil.wrapColor(teacher
					.getName(), Color.green)
					+ "已成为您的师傅!出师即可获得丰厚奖励。");
		} else {
			// 拒绝
			MmochatUtil.sendCommonMsgbox(teacher, MmochatUtil.wrapColor(student
					.getName(), Color.green)
					+ "拒绝成为您的徒弟。");
		}
		return null;
	}

	// 9.9 脱离师傅
	@SkymobiService
	public SkymobiProtocolMessage handleC_9_9(SkymobiHandler handler,
			Mmochat_9_9C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		if (!me.hasTeacher()) {
			return MmochatUtil.msgbox(req.getHallState(), "您还没有师傅!");
		}
		MmochatPlayer he = MmochatMainService.getRoleFromBuffer(me
				.getTeacher_roleId());
		if (he == null) {
			try {
				he = MmochatDao.getRole(me.getTeacher_roleId());
			} catch (EmptyResultDataAccessException e) {
				// 师傅可能已删号
				int teacherRoleId = me.getTeacher_roleId();
				String teacherName = me.getTeacher_name();
				me.setNoTeacher();
				try {
					MmochatDao.updateRoleTeacherAndStudent(me);
				} catch (Exception e1) {
					e1.printStackTrace();
					me.setTeacher(teacherRoleId, teacherName);
					return MmochatUtil
							.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
				}
				return MmochatUtil.msgbox(req.getHallState(), "您已经脱离了师门。");
			} catch (Exception e) {
				e.printStackTrace();
				return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
			}
		}
		if (he == null) {
			// 师傅可能已删号
			int teacherRoleId = me.getTeacher_roleId();
			String teacherName = me.getTeacher_name();
			me.setNoTeacher();
			try {
				MmochatDao.updateRoleTeacherAndStudent(me);
			} catch (Exception e) {
				e.printStackTrace();
				me.setTeacher(teacherRoleId, teacherName);
				return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
			}
			return MmochatUtil.msgbox(req.getHallState(), "您已经脱离了师门。");
		}

		// 脱离师傅
		me.setNoTeacher();
		he.delStudent((Integer) me.getRoleId());
		try {
			MmochatDao.updateRoleTeacherAndStudent(he, me);
		} catch (Exception e) {
			e.printStackTrace();
			me.setTeacher(he.getRoleId(), he.getName());
			he.addStudent(me);
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}

		MmochatChenHao.delAndUpdateChenHaoAndSaveSql(me.getRoleId(),
				MmochatChenHaoType.徒弟);

		if (MmochatMainService.isPlayerOnline(he.getRoleId())) {
			MmochatFriendService.sendSystemMsgToPersonByFriendMessage(he,
					MmochatUtil.wrapColor(me.getName(), Color.green)
							+ "脱离了您的师门!");
		}
		return MmochatUtil.msgbox(req.getHallState(), "您已经脱离了" + he.getName()
				+ "的师门。");
	}

	// 9.10 踢除徒弟
	@SkymobiService
	public SkymobiProtocolMessage handleC_9_10(SkymobiHandler handler,
			Mmochat_9_10C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		MmochatPlayer student = MmochatMainService.getRoleFromBuffer(req
				.getHisRoleId());
		if (student != null) {
			student.setNoTeacher();
		}
		String stuName = me.getStudents().get(req.getHisRoleId());
		me.delStudent(req.getHisRoleId());
		try {
			MmochatDao.kickOutStudent(me, req.getHisRoleId());
		} catch (Exception e) {
			e.printStackTrace();
			if (stuName != null) {
				me.addStudent(req.getHisRoleId(), stuName);
			}
			if (student != null) {
				student.setTeacher(me.getRoleId(), me.getName());
			}
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}

		MmochatChenHao.delAndUpdateChenHaoAndSaveSql(req.getHisRoleId(),
				MmochatChenHaoType.徒弟);

		if (me.getStudents().size() == 0) {
			CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
			msgbox.setContent(new Text("您已经没有徒弟了!"));
			msgbox.setLeftName("确定");

			return MmochatUtil.tlvResponse(req.getHallState(), new CloseWinTLV(
					MmochatConstant.TLV_WIN_STUDENTLIST), msgbox);
		}

		CreateTlvWin tlv = new CreateTlvWin();
		tlv.setWinType(WinType.List);
		tlv.setLeftName("踢除");
		tlv.setRightName("返回");
		tlv.setTitle("我的徒弟");
		tlv.setWinHeight(208);
		tlv.setWinId(MmochatConstant.TLV_WIN_STUDENTLIST);
		tlv.addRightTLV(new CloseWinTLV(MmochatConstant.TLV_WIN_STUDENTLIST));

		for (Entry<Integer, String> entry : me.getStudents().entrySet()) {
			int roleId = entry.getKey();
			String name = entry.getValue();
			tlv.addItemEvent(name, new ClearDataTLV(), new AddDataTLV(
					(int) roleId));
		}

		CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
		msgbox.setContent(new Text("您确定要将此人逐出师门么?"));
		msgbox.setLeftName("确定");
		msgbox.setRightName("取消");
		msgbox.addLeftTLV(new SendDataTLV(MmochatConstant.getClientModuleId(),
				MmochatMain.getModuleInstID(),
				MmochatConstant.MSGCODE_MMOCHAT_C_9_10, (int) me.getRoleId()));
		ShowWaitingMsgBoxTLV wait = new ShowWaitingMsgBoxTLV();
		wait.setShowCancel(false);
		msgbox.addLeftTLV(wait);
		tlv.addLeftTLV(msgbox);

		return MmochatUtil.tlvResponse(req.getHallState(), new CloseWinTLV(
				MmochatConstant.TLV_WIN_STUDENTLIST), tlv);
	}

	// 9.12 回收物品
	@SkymobiService
	public SkymobiProtocolMessage handleC_9_12(SkymobiHandler handler,
			Mmochat_9_12C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		MmochatPackageGrid grid;
		MmochatCommonObject obj;

		// 回收改造过的装备、粉装、绿装都要验证密码
		grid = me.getMyPackage().get(req.getGridId());
		if (grid == null || !grid.isCanUse() || grid.getObject() == null) {
			return null;
		}
		obj = grid.getObject();
		if (!obj.canSell()) {
			return MmochatUtil.msgbox(req.getHallState(), "此物品不能回收!");
		}

		if (checkStorePwd(me)) {
			return null;
		}

		synchronized (me) {
			grid = me.getMyPackage().get(req.getGridId());
			if (grid == null || !grid.isCanUse() || grid.getObject() == null) {
				return null;
			}
			obj = grid.getObject();
			if (!obj.canSell()) {
				return MmochatUtil.msgbox(req.getHallState(), "此物品不能回收!");
			}
			if (obj.getOverlapNum() <= 0) {
				return null;
			}
			grid.setObject(null);

			try {
				if (obj.getEquipModifyLevel() > 0
						|| obj.getEquipPinkAttr() != null
						|| obj.getEquipGreenDarkAttr() != null
						|| obj.getEquipType() == MmochatEquipType.玉佩
						|| obj.getEquipType() == MmochatEquipType.挂坠
						|| obj.getEquipType() == MmochatEquipType.手镯
						|| obj.getObjectType() == MmochatObjectType.法宝) {
					// 回收记录
					List<MmochatCommonObject> list = soldToSystemObjMap.get(me
							.getRoleId());
					if (list == null) {
						list = new ArrayList<MmochatCommonObject>();
					}
					list.add(obj);
					soldToSystemObjMap.put(me.getRoleId(), list);
				}
			} catch (Exception e) {
			}
		}
		int price = obj.getPriceOfSellToSystem() * obj.getOverlapNum();

		try {
			MmochatDao.sellEquip(me, price);
		} catch (Exception e) {
			e.printStackTrace();
			grid.setObject(obj);
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}

		me.addSmall_money(price);
		MmochatStatisticsService.addSmallMoneyEarn(
				MmochatSmallMoneyEarnType.回收装备, price);

		// 更新包裹和游戏币
		Mmochat_5_31S pack1 = new Mmochat_5_31S();
		pack1.setSmallMoney((int) me.getSmall_money());
		MmochatUtil.sendCommonPack(me, pack1);

		Mmochat_5_1S pack = new Mmochat_5_1S();
		pack.addGrid(grid);
		MmochatUtil.sendCommonPack(me, pack);

		return null;
	}

	private static CreateTlvWin getSuggestScore2BigMoneyTlv(MmochatPlayer me) {
		CreateTlvWin tlv = new CreateTlvWin();
		tlv.setWinType(WinType.Text);
		tlv.setLeftName("兑换");
		tlv.setRightName("返回");
		tlv.setTitle("积分兑换元宝");
		tlv.setWinHeight(188);
		tlv.setWinId(MmochatConstant.TLV_WIN_SUGGESTSCORE_2MONEY);
		tlv.addRightTLV(new CloseWinTLV(
				MmochatConstant.TLV_WIN_SUGGESTSCORE_2MONEY));
		String content = MmochatUtil.wrapColor("1积分可兑换1元宝。兑换没有数量限制。\n\n",
				Color.green);
		content += MmochatUtil.wrapColor("您当前拥有:\n积分:" + me.getSuggestScore()
				+ "\n元宝:" + me.getBig_money(), Color.yellow);
		tlv.setContent(new Text(content));

		CreateEditBoxTLV edit = new CreateEditBoxTLV();
		edit.setTitle("请输入要兑换的积分数量!");
		edit.setLeftName("兑换");
		edit.setRightName("取消");
		edit.setContentLenMax(8);
		edit.setBoxType(CreateEditBoxTLV.TYPE_MSGBOX);
		edit.setInputType(CreateEditBoxTLV.INPUT_NUM << 4);
		edit.addLeftTLV(new ClearDataTLV());
		edit.addLeftTLV(new AddEditBoxTLV());
		edit.addLeftTLV(new SendDataTLV(MmochatConstant.getClientModuleId(),
				MmochatMain.getModuleInstID(),
				MmochatConstant.MSGCODE_MMOCHAT_C_9_13, (int) me.getRoleId()));
		ShowWaitingMsgBoxTLV wait = new ShowWaitingMsgBoxTLV();
		wait.setShowCancel(false);
		edit.addLeftTLV(wait);
		tlv.addLeftTLV(edit);
		return tlv;
	}

	// 9.13 积分兑换元宝
	@SkymobiService
	public SkymobiProtocolMessage handleC_9_13(SkymobiHandler handler,
			Mmochat_9_13C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		int num = 0;
		try {
			num = Integer.parseInt(req.getCount());
		} catch (NumberFormatException e) {
			return MmochatUtil.msgbox(req.getHallState(),
					"只能输入数字,请重新输入要兑换的积分数量!");
		}
		if (num <= 0) {
			return MmochatUtil.msgbox(req.getHallState(), "请输入大于0的数字!");
		}
		if (me.getSuggestScore() < num) {
			return MmochatUtil.msgbox(req.getHallState(), "您的积分不足!");
		}
		synchronized (me) {
			if (me.getSuggestScore() >= num) {
				me.addSuggestScore(-1 * num);
				me.addBig_money(num);
			} else {
				return MmochatUtil.msgbox(req.getHallState(), "您的积分不足!");
			}
		}
		try {
			MmochatDao.updateSuggestScoreAndBigmoney(num, num, me.getRoleId());
		} catch (Exception e) {
			e.printStackTrace();
			me.addSuggestScore(num);
			me.addBig_money(-1 * num);
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		MmochatStatisticsService.addBigMoneyEarn(
				MmochatBigMoneyEarnType.积分兑换元宝, num);
		MmochatStatisticsService.todayScore2BigMoneyCount += num;

		CreateTlvWin tlv = getSuggestScore2BigMoneyTlv(me);
		return MmochatUtil.tlvResponse(req.getHallState(), new CloseWinTLV(
				MmochatConstant.TLV_WIN_SUGGESTSCORE_2MONEY), tlv);
	}

	// 9.14 结婚
	@SkymobiService
	public SkymobiProtocolMessage handleC_9_14(SkymobiHandler handler,
			Mmochat_9_14C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}

		if (!me.isInTeam()) {
			return MmochatUtil.msgbox(req.getHallState(),
					"请和您想要结婚的对象一起组队来我这里!只能两人组队噢。");
		}
		if (MmochatTeamService.getTeamState(me) != MmochatTeamStateType.队长) {
			return MmochatUtil.msgbox(req.getHallState(),
					"请和您想要结婚的对象一起组队来我这里!只能两人组队噢。");
		}
		MmochatTeam team = MmochatTeamService.teams.get(me.getTeamId());
		if (team == null) {
			me.leaveTeam();
			return MmochatUtil.msgbox(req.getHallState(),
					"请和您想要结婚的对象一起组队来我这里!只能两人组队噢。");
		}
		if (team.getMemberId().size() != 2) {
			return MmochatUtil.msgbox(req.getHallState(),
					"请组上您想要结婚的对象，只能两人组队噢，不要组上无关人员。");
		}
		MmochatPlayer he = null;
		for (Integer roleId : team.getMemberId().values()) {
			if (roleId != me.getRoleId()) {
				he = MmochatMainService.players.get(roleId);
				break;
			}
		}
		if (he == null) {
			return MmochatUtil.msgbox(req.getHallState(), "对方已掉线，请稍后再来!");
		}

		if (me.getWife_roleId() != -1) {
			return MmochatUtil.msgbox(req.getHallState(), "您已经有配偶了，不能再结婚了!");
		}
		if (he.getWife_roleId() != -1) {
			return MmochatUtil.msgbox(req.getHallState(), "对方已经有配偶了，不能再结婚了!");
		}
		if (me.getSexual() == he.getSexual()) {
			return MmochatUtil.msgbox(req.getHallState(), "根据婚姻法，同性不能结婚!");
		}
		MmochatFriend f1 = me.getMyDearFriends().get(he.getRoleId());
		if (f1 == null) {
			return MmochatUtil.msgbox(req.getHallState(), "对方还不是您的好友，不能结婚!");
		}
		MmochatFriend f2 = he.getMyDearFriends().get(me.getRoleId());
		if (f2 == null) {
			return MmochatUtil.msgbox(req.getHallState(), "对方还没有加您为好友，不能结婚!");
		}
		if (f1.getFriendValue() < MmochatConstant.friendValueNeedToMarry) {
			return MmochatUtil.msgbox(req.getHallState(), "您与对方的好友度为"
					+ f1.getFriendValue()
					+ "点，好友度至少要"
					+ MmochatUtil.wrapColor(
							MmochatConstant.friendValueNeedToMarry,
							Color.yellow) + "点才能结婚!好友度可以通过组队打怪获得。");
		}
		if (f2.getFriendValue() < MmochatConstant.friendValueNeedToMarry) {
			return MmochatUtil.msgbox(req.getHallState(), "对方与您的好友度为"
					+ f2.getFriendValue()
					+ "点，好友度至少要"
					+ MmochatUtil.wrapColor(
							MmochatConstant.friendValueNeedToMarry,
							Color.yellow) + "点才能结婚!好友度可以通过组队打怪获得。");
		}

		String msg = MmochatUtil.wrapColor(me.getName(), Color.green)
				+ "希望与你结为夫妻，你愿意么?";
		CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
		msgbox.setContent(new Text(msg));
		msgbox.setLeftName("愿意");
		msgbox.setRightName("拒绝");

		msgbox.addLeftTLV(new ClearDataTLV());
		msgbox.addLeftTLV(new AddDataTLV((int) me.getRoleId()));
		msgbox.addLeftTLV(new AddDataTLV((int) he.getRoleId()));
		msgbox.addLeftTLV(new SendDataTLV(MmochatConstant.getClientModuleId(),
				MmochatMain.getModuleInstID(),
				MmochatConstant.MSGCODE_MMOCHAT_C_9_15, (int) 1));

		msgbox.addRightTLV(new ClearDataTLV());
		msgbox.addRightTLV(new AddDataTLV((int) me.getRoleId()));
		msgbox.addRightTLV(new AddDataTLV((int) he.getRoleId()));
		msgbox.addRightTLV(new SendDataTLV(MmochatConstant.getClientModuleId(),
				MmochatMain.getModuleInstID(),
				MmochatConstant.MSGCODE_MMOCHAT_C_9_15, (int) 0));

		CtrlTLVStructureRequest pack = MmochatUtil
				.tlvResponseWithoutHallState(msgbox);
		MmochatUtil.sendCommonPack(he, pack);
		return MmochatUtil
				.msgbox(req.getHallState(), "那我询问下"
						+ MmochatUtil.wrapColor(he.getName(), Color.green)
						+ "的意愿，请稍候。");
	}

	// 9.15 结婚时另一伴的意愿
	@SkymobiService
	public SkymobiProtocolMessage handleC_9_15(SkymobiHandler handler,
			Mmochat_9_15C req) {
		MmochatPlayer role1 = MmochatMainService.players.get(req.getRoleId1());
		MmochatPlayer role2 = MmochatMainService.players.get(req.getRoleId2());
		if (role1 == null) {
			if (role2 != null) {
				MmochatUtil.sendCommonMsgbox(role2, "对方掉线，请下次再来");
			}
		}
		if (role2 == null) {
			if (role1 != null) {
				MmochatUtil.sendCommonMsgbox(role1, "对方掉线，请下次再来");
			}
		}
		if (req.getRet() == 1) {
			// 同意
			if (role1.getSmall_money() < MmochatConstant.moneyCostToMarry) {
				MmochatUtil
						.sendCommonMsgbox(
								role1,
								"结婚手续需要"
										+ MmochatUtil
												.getColorMoney(MmochatConstant.moneyCostToMarry)
										+ "文钱，您包裹里的金钱不足，请准备好了再来吧。");
				MmochatUtil
						.sendCommonMsgbox(
								role2,
								"结婚手续需要"
										+ MmochatUtil
												.getColorMoney(MmochatConstant.moneyCostToMarry)
										+ "文钱，"
										+ MmochatUtil.wrapColor(
												role1.getName(), Color.green)
										+ "携带的金钱不足，请你们回去准备好了再来吧。");
				return null;
			}
			role1
					.addAndUpdateSmall_money(-1
							* MmochatConstant.moneyCostToMarry);
			role1.setWife(role2.getRoleId(), role2.getName());
			role2.setWife(role1.getRoleId(), role1.getName());

			// 保存数据库
			try {
				// 保存夫妻关系和金钱
				MmochatDao
						.marry(role1, role2, MmochatConstant.moneyCostToMarry);
			} catch (Exception e) {
				e.printStackTrace();
				role1.addAndUpdateSmall_money(MmochatConstant.moneyCostToMarry);
				role2.setNoWife();
				role1.setNoWife();

				MmochatUtil.sendCommonMsgbox(role1, "数据库忙，请稍候再试。");
				MmochatUtil.sendCommonMsgbox(role2, "数据库忙，请稍候再试。");
				return null;
			}
			// 称号
			if (role1.getSexual() == 0) {
				// role1是男
				MmochatChenHao chenhao = new MmochatChenHao();
				chenhao.setType(MmochatChenHaoType.相公);
				chenhao.setName(role2.getName() + "的"
						+ chenhao.getType().toString());
				chenhao.setExtraEffectInfo("夫妻同心:与配偶组队时，气血增加10%");
				MmochatChenHao.addAndUpdateChenHaoAndSaveSql(role1.getRoleId(),
						chenhao);

				chenhao = new MmochatChenHao();
				chenhao.setType(MmochatChenHaoType.娘子);
				chenhao.setName(role1.getName() + "的"
						+ chenhao.getType().toString());
				chenhao.setExtraEffectInfo("夫妻同心:与配偶组队时，气血增加10%");
				MmochatChenHao.addAndUpdateChenHaoAndSaveSql(role2.getRoleId(),
						chenhao);
			} else {
				// role1是女
				MmochatChenHao chenhao = new MmochatChenHao();
				chenhao.setType(MmochatChenHaoType.相公);
				chenhao.setName(role1.getName() + "的"
						+ chenhao.getType().toString());
				chenhao.setExtraEffectInfo("夫妻同心:与配偶组队时，气血增加10%");
				MmochatChenHao.addAndUpdateChenHaoAndSaveSql(role2.getRoleId(),
						chenhao);

				chenhao = new MmochatChenHao();
				chenhao.setType(MmochatChenHaoType.娘子);
				chenhao.setName(role2.getName() + "的"
						+ chenhao.getType().toString());
				chenhao.setExtraEffectInfo("夫妻同心:与配偶组队时，气血增加10%");
				MmochatChenHao.addAndUpdateChenHaoAndSaveSql(role1.getRoleId(),
						chenhao);
			}

			MmochatStatisticsService.addSmallMoneyCost(
					MmochatSmallMoneyCostType.结婚, -1
							* MmochatConstant.moneyCostToMarry);
			MmochatUtil.sendCommonMsgbox(role1, MmochatUtil.wrapColor("恭喜恭喜!您与"
					+ MmochatUtil.wrapColor(role2.getName(), Color.green)
					+ "成功结为夫妻。祝你们永结同心，白头偕老!", Color.yellow));
			MmochatUtil.sendCommonMsgbox(role2, MmochatUtil.wrapColor("恭喜恭喜!您与"
					+ MmochatUtil.wrapColor(role1.getName(), Color.green)
					+ "成功结为夫妻。祝你们永结同心，白头偕老!", Color.yellow));
			MmochatChatService.sendSystemMsg(MmochatUtil.wrapColor("恭喜"
					+ MmochatUtil.wrapColor(role1.getName(), Color.yellow)
					+ MmochatUtil.wrapIcon(MmochatConstant.BMP_EMOTION_35)
					+ MmochatUtil.wrapColor(role2.getName(), Color.yellow)
					+ "喜结连理!祝他们永结同心，白头偕老!", Color.red));
		} else {
			// 拒绝
			MmochatUtil.sendCommonMsgbox(role1, MmochatUtil.wrapColor(role2
					.getName(), Color.green)
					+ "拒绝与您结为夫妻，请你们回去再商量一下。");
		}
		return null;
	}

	// 9.16 离婚
	@SkymobiService
	public SkymobiProtocolMessage handleC_9_16(SkymobiHandler handler,
			Mmochat_9_16C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		if (!me.hasWife()) {
			return MmochatUtil.msgbox(req.getHallState(), "您还没有结婚!");
		}
		MmochatPlayer he = MmochatMainService.getRoleFromBuffer(me
				.getWife_roleId());
		if (he == null) {
			try {
				he = MmochatDao.getRole(me.getWife_roleId());
			} catch (EmptyResultDataAccessException e) {
				// 配偶可能已删号
				int wifeRoleId = me.getWife_roleId();
				String wifeName = me.getWife_name();
				me.setNoWife();
				try {
					MmochatDao.unMarry(me, null);
				} catch (Exception e1) {
					e1.printStackTrace();
					me.setWife(wifeRoleId, wifeName);
					return MmochatUtil
							.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
				}
				return MmochatUtil
						.msgbox(req.getHallState(), "离婚成功!祝你找到真正的至爱。");
			} catch (Exception e) {
				e.printStackTrace();
				return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
			}
		}
		if (he == null) {
			// 配偶可能已删号
			int wifeRoleId = me.getWife_roleId();
			String wifeName = me.getWife_name();
			me.setNoWife();
			try {
				MmochatDao.unMarry(me, null);
			} catch (Exception e1) {
				e1.printStackTrace();
				me.setWife(wifeRoleId, wifeName);
				return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
			}
			return MmochatUtil.msgbox(req.getHallState(), "离婚成功!祝你找到真正的至爱。");
		}

		// 离婚
		me.setNoWife();
		he.setNoWife();
		try {
			MmochatDao.unMarry(me, he);
		} catch (Exception e) {
			e.printStackTrace();
			me.setWife(he.getRoleId(), he.getName());
			he.setWife(me.getRoleId(), me.getName());
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		MmochatChenHao.delAndUpdateChenHaoAndSaveSql(me.getRoleId(),
				MmochatChenHaoType.相公);
		MmochatChenHao.delAndUpdateChenHaoAndSaveSql(me.getRoleId(),
				MmochatChenHaoType.娘子);
		MmochatChenHao.delAndUpdateChenHaoAndSaveSql(he.getRoleId(),
				MmochatChenHaoType.相公);
		MmochatChenHao.delAndUpdateChenHaoAndSaveSql(he.getRoleId(),
				MmochatChenHaoType.娘子);

		MmochatGmService.sendKufuPrivateMsg(he.getRoleId(), MmochatUtil
				.wrapColor(me.getName(), Color.green)
				+ "已经申请与您离婚成功，你们已不再是夫妻!你俩虽没夫妻之缘，但也可以成为好朋友。", false);
		return MmochatUtil.msgbox(req.getHallState(), "离婚成功!祝你找到真正的至爱。");
	}

	// 9.17 查看装备满属
	@SkymobiService
	public SkymobiProtocolMessage handleC_9_17(SkymobiHandler handler,
			Mmochat_9_17C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		MmochatEquipType equipType = MmochatEquipType.get(req
				.getEquipTypeValue());
		if (equipType == null) {
			return MmochatUtil.msgbox(req.getHallState(), "暂无数据!");
		}
		List<MmochatEquipAttributeType> randAttrList = MmochatEquipService
				.getEquipRandAttributeTypesWithoutOverlap(equipType);
		if (randAttrList == null || randAttrList.size() == 0) {
			return MmochatUtil.msgbox(req.getHallState(), "没有附加属性!");
		}

		CreateTlvWin tlv = new CreateTlvWin();
		tlv.setWinType(WinType.List);
		tlv.setLeftName("查看");
		tlv.setRightName("返回");
		tlv.setTitle(equipType.toString());
		tlv.setWinHeight(208);
		tlv.addRightTLV(new CloseWinTLV());

		for (MmochatEquipAttributeType type : randAttrList) {
			tlv.addItemEvent(type.getStartInfo(), new ClearDataTLV(),
					new AddDataTLV((int) type.getValue()));
		}
		tlv.addLeftTLV(new AddDataTLV(req.getEquipTypeValue()));
		tlv.addLeftTLV(new SendDataTLV(MmochatConstant.getClientModuleId(),
				MmochatMain.getModuleInstID(),
				MmochatConstant.MSGCODE_MMOCHAT_C_9_18, (int) me.getRoleId()));
		tlv.addLeftTLV(new ShowWaitingMsgBoxTLV());

		return MmochatUtil.tlvResponse(req.getHallState(), tlv);
	}

	// 9.18 查看装备满属
	@SkymobiService
	public SkymobiProtocolMessage handleC_9_18(SkymobiHandler handler,
			Mmochat_9_18C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		MmochatEquipType equipType = MmochatEquipType.get(req
				.getEquipTypeValue());
		if (equipType == null) {
			return MmochatUtil.msgbox(req.getHallState(), "暂无数据!");
		}
		MmochatEquipAttributeType attrType = MmochatEquipAttributeType.get(req
				.getAttrTypeValue());
		if (attrType == null) {
			return MmochatUtil.msgbox(req.getHallState(), "暂无数据!");
		}

		Map<MmochatEquipAttributeType, Map<Integer, Integer[]>> m1 = MmochatEquipService.equipRandAttrData
				.get(equipType);
		if (m1 == null) {
			return MmochatUtil.msgbox(req.getHallState(), "暂无数据!");
		}
		Map<Integer, Integer[]> m2 = m1.get(attrType);
		if (m2 == null) {
			return MmochatUtil.msgbox(req.getHallState(), "暂无数据!");
		}

		List<MmochatEquipAttributeType> randAttrList = MmochatEquipService
				.getEquipAttributeTypes(equipType,
						MmochatEquipAttributeQualityType.附加属性);
		int overlapNum = 0;// 同一件装备中可出现的最大条数
		for (MmochatEquipAttributeType type : randAttrList) {
			if (type == attrType) {
				overlapNum++;
			}
		}

		CreateTlvWin tlv = new CreateTlvWin();
		tlv.setWinType(WinType.Text);
		tlv.setRightName("返回");
		tlv.setTitle(attrType.getStartInfo());
		tlv.setWinHeight(208);
		tlv.addRightTLV(new CloseWinTLV());
		String content = "";
		content += MmochatUtil.wrapColor(
				"同一件装备中最多允许出现" + overlapNum + "条此属性\n", Color.magenta);

		for (int i = 0; i <= MmochatConstant.equipMaxLevel; i++) {
			Integer[] m3 = m2.get(i);
			if (m3 != null) {
				content += "\n"
						+ MmochatUtil.wrapColor("[" + i + "级"
								+ equipType.toString() + "]", Color.yellow)
						+ "\n";
				content += "最小属性值:" + m3[0] + "\n";
				content += "最大属性值:" + m3[1] + "\n";
			}
		}
		tlv.setContent(new Text(content));
		return MmochatUtil.tlvResponse(req.getHallState(), tlv);
	}

	// 9.19 提升好友度
	@SkymobiService
	public SkymobiProtocolMessage handleC_9_19(SkymobiHandler handler,
			Mmochat_9_19C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}

		if (!me.isInTeam()) {
			return MmochatUtil.msgbox(req.getHallState(),
					"请和您想要提升好友度的的朋友一起组队来我这里!只能两人组队噢。");
		}
		if (MmochatTeamService.getTeamState(me) != MmochatTeamStateType.队长) {
			return MmochatUtil.msgbox(req.getHallState(),
					"请和您想要提升好友度的的朋友一起组队来我这里!只能两人组队噢。");
		}
		MmochatTeam team = MmochatTeamService.teams.get(me.getTeamId());
		if (team == null) {
			me.leaveTeam();
			return MmochatUtil.msgbox(req.getHallState(),
					"请和您想要提升好友度的的朋友一起组队来我这里!只能两人组队噢。");
		}
		if (team.getMemberId().size() != 2) {
			return MmochatUtil.msgbox(req.getHallState(), "只能两人组队噢，您的队伍中人数过多。");
		}
		MmochatPlayer he = null;
		for (Integer roleId : team.getMemberId().values()) {
			if (roleId != me.getRoleId()) {
				he = MmochatMainService.players.get(roleId);
				break;
			}
		}
		if (he == null) {
			return MmochatUtil.msgbox(req.getHallState(), "对方已掉线，请稍后再来!");
		}

		MmochatFriend f1 = me.getMyDearFriends().get(he.getRoleId());
		if (f1 == null) {
			return MmochatUtil.msgbox(req.getHallState(), "对方还不是您的好友，不能提升好友度!");
		}
		MmochatFriend f2 = he.getMyDearFriends().get(me.getRoleId());
		if (f2 == null) {
			return MmochatUtil
					.msgbox(req.getHallState(), "对方还没有加您为好友，不能提升好友度!");
		}
		if (me.getBig_money() < 100) {
			return MmochatUtil.msgbox(req.getHallState(), "您的元宝不足100,请先充值!");
		}
		synchronized (me) {
			if (me.getBig_money() < 100) {
				return MmochatUtil
						.msgbox(req.getHallState(), "您的元宝不足100,请先充值!");
			}
			f1.addFriendValue(100);
			f2.addFriendValue(100);
			long oldLimit = me.getLimit_bigmoney();
			me.addLimit_bigmoney(-1 * 100);
			try {
				MmochatDao.updateMyFriendsAndDelBigMoney(me, 100, he);
			} catch (Exception e) {
				e.printStackTrace();
				f1.addFriendValue(-100);
				f2.addFriendValue(-100);
				me.setLimit_bigmoney(oldLimit);
				return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
			}
			me.addBig_money(-100);
			MmochatStatisticsService.todayBigMoneyCost += 100;
		}
		return MmochatUtil.msgbox(req.getHallState(), "恭喜!您与"
				+ MmochatUtil.wrapColor(he.getName(), Color.green)
				+ "的好友度增加了100点。");
	}

	// 9.20 道行子榜
	@SkymobiService
	public SkymobiProtocolMessage handleC_9_20(SkymobiHandler handler,
			Mmochat_9_20C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		int level = req.getLevel();
		List<MmochatRankPlayer> rank = null;
		String title = "";
		if (level == -1) {
			// 总榜
			rank = daoRank;
			title = "总榜";
		} else {
			rank = daoRankOfLevel.get(level);
			title = level + "-" + (level + 9) + "级榜";
		}
		if (rank == null || rank.size() == 0) {
			return MmochatUtil.msgbox(req.getHallState(), "暂时还没有此榜!");
		}

		CreateTlvWin tlv = new CreateTlvWin();
		tlv.setWinType(WinType.List);
		tlv.setRightName("返回");
		tlv.setTitle(title);
		tlv.setWinHeight(188);
		tlv.addRightTLV(new CloseWinTLV());
		int index = 1;
		for (MmochatRankPlayer player : rank) {
			String item = index + ".";
			if (player.getRoleId() == me.getRoleId()) {
				item += MmochatUtil.wrapColor(player.getName(), Color.green);
			} else {
				item += MmochatUtil.wrapColor(player.getName(), Color.yellow);
			}
			item += "\n" + MmochatUtil.getDaoSimpleString(player.getDao());
			tlv.addItemEvent(player.getBmpId(), item);
			index++;
		}
		return MmochatUtil.tlvResponse(req.getHallState(), tlv);
	}

	// 9.21 转生选项
	@SkymobiService
	public SkymobiProtocolMessage handleC_9_21(SkymobiHandler handler,
			Mmochat_9_21C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		if (req.getIndex() == 1) {
			// 转生说明
			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinType(WinType.Text);
			tlv.setRightName("返回");
			tlv.setTitle("转生说明");
			tlv.setWinHeight(188);
			tlv.addRightTLV(new CloseWinTLV());
			String content = MmochatUtil.wrapColor("[关于转生]\n", Color.yellow);
			content += "每个人都有一个极限，当他的修为越来越接近这个极限时，"
					+ "进阶将变得非常困难，甚至停滞不前。为了助我派弟子得道成仙，我会在大家达到这个极限时，"
					+ "帮大家突破这个极限，实现转生，进入下一个修为境界。\n\n";

			content += MmochatUtil.wrapColor("[转生条件]\n", Color.yellow);
			content += "转生需要达到一定条件才可以进行：";
			content += "\n1、等级达到" + MmochatConstant.maxLevel
					+ "级，并且经验达到129级升级经验。";
			content += "\n2、道行达到一定要求(具体在转生时会进行提示)\n\n";

			content += MmochatUtil.wrapColor("[转生变化]\n", Color.yellow);
			content += MmochatUtil.wrapColor("1、数值变化\n", Color.green);
			content += "第N次转生后，等级降为120级，道行不变。4项属性点各为120点，可分配属性点＝480+80*N，"
					+ "各项天赋点清0，可分配天赋点＝60+5*N\n";
			content += MmochatUtil.wrapColor("2、标准道行\n", Color.green);
			content += "第N次转生后的标准道行＝(等级+N*10)*(等级+N*10)*(等级+N*10)*0.29(天)。\n";
			content += MmochatUtil.wrapColor("3、魔仙选择\n", Color.green);
			content += "第1次转生时可以选择入魔还是入仙。入魔者在进化装备时，装备将被灌注物理系伤害，"
					+ "转生后各项天赋点可分配上限提高5点，可以学习魔系转生技能；"
					+ "入仙者在进化装备时，装备将被灌注法术系伤害，"
					+ "转生后各项天赋点可分配上限提高5点，可以学习仙系转生技能。\n";
			content += MmochatUtil.wrapColor("4、转生装备\n", Color.green);
			content += "人物转生后可以到兵器店将装备进行进化，进化后的装备将拥有转生力量。"
					+ "人物N转后，才能进行第N次装备进化。未转生玩家无法驾驭转生装备。\n";
			content += MmochatUtil.wrapColor("5、转生宠物\n", Color.green);
			content += "人物转生后可以帮助宠物进行转生。到"
					+ MmochatUtil.wrapColor("开封(74,134)", Color.yellow)
					+ "找螭吻进行宠物转生。宠物需要达到129级满经验才能转生，转生后宠物回到120级，实力也将得到提升。";

			tlv.setContent(new Text(content));
			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		} else if (req.getIndex() == 2) {
			// 我要转生
			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinType(WinType.Text);
			tlv.setLeftName("转生");
			tlv.setRightName("返回");
			tlv.setTitle("我要转生");
			tlv.setWinHeight(188);
			tlv.addRightTLV(new CloseWinTLV());
			String content = "";
			boolean conditionIsOk = true;
			if (me.getLife_turn() >= MmochatConstant.maxLifeTurn) {
				content += MmochatUtil.wrapColor("您已经达到最高转生次数，无法再转生!",
						Color.red);
				conditionIsOk = false;
			} else {
				content += MmochatUtil.wrapColor(
						"当前已转生次数:" + me.getLife_turn(), Color.magenta);
				content += MmochatUtil.wrapColor("\n进行第"
						+ (me.getLife_turn() + 1) + "次转生\n\n", Color.magenta);

				content += MmochatUtil.wrapColor("[转生条件]\n", Color.yellow);
				content += "1、等级要求达到" + MmochatConstant.maxLevel
						+ "级，并且经验达到129级升级经验。";
				if (me.getLevel() == 129) {
					content += MmochatUtil.wrapColor("\n-等级达到要求", Color.green);
				} else {
					content += MmochatUtil.wrapColor("\n-等级未达到要求", Color.red);
					conditionIsOk = false;
				}

				if (me.getExp() >= MmochatBattleService
						.getHumanExpNeedToUplevel(me.getLevel(), me
								.getLife_turn())) {
					content += MmochatUtil.wrapColor("\n-经验达到要求", Color.green);
				} else {
					content += MmochatUtil.wrapColor("\n-经验未达到要求", Color.red);
					conditionIsOk = false;
				}

				int daoNeed = MmochatBattleService.getStandardDao(129, me
						.getLife_turn()) * 2;
				content += "\n\n2、道行要求达到" + MmochatUtil.getDaoString(daoNeed);
				if (me.getDao() >= daoNeed) {
					content += MmochatUtil.wrapColor("\n-道行达到要求", Color.green);
				} else {
					content += MmochatUtil.wrapColor("\n-道行未达到要求", Color.red);
					conditionIsOk = false;
				}

				if (me.getLife_turn() == 0) {
					content += "\n\n3、您是第一次转生，需要选择魔道还是仙道。"
							+ MmochatUtil
									.wrapColor(
											"选择魔道则按<转生>按钮后输入数字1，选择仙道则按<转生>按钮后输入数字2。魔道与仙道的介绍请查看<转生说明>",
											Color.magenta);
				}
			}

			tlv.setContent(new Text(content));

			// 判断条件是否满足
			if (!conditionIsOk) {
				CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
				msgbox.setContent(new Text("您未达到转生条件!"));
				msgbox.setLeftName("确定");
				tlv.addLeftTLV(msgbox);
			} else {
				if (me.getLife_turn() == 0) {
					// 需要选择入魔道还是仙道
					CreateEditBoxTLV edit = new CreateEditBoxTLV();
					edit.setTitle("输入数字1进入魔道，输入数字2进入仙道!选择后无法变更。");
					edit.setLeftName("确定");
					edit.setRightName("取消");
					edit.setContentLenMax(1);
					edit.setBoxType(CreateEditBoxTLV.TYPE_MSGBOX);
					edit.setInputType(CreateEditBoxTLV.INPUT_ANY << 4);
					edit.addLeftTLV(new ClearDataTLV());
					edit.addLeftTLV(new AddDataTLV((int) me.getRoleId()));
					edit.addLeftTLV(new AddEditBoxTLV());
					edit.addLeftTLV(new SendDataTLV(MmochatConstant
							.getClientModuleId(),
							MmochatMain.getModuleInstID(),
							MmochatConstant.MSGCODE_MMOCHAT_C_9_22, null));
					ShowWaitingMsgBoxTLV wait = new ShowWaitingMsgBoxTLV();
					wait.setShowCancel(false);
					edit.addLeftTLV(wait);
					tlv.addLeftTLV(edit);
				} else {
					CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
					msgbox.setContent(new Text("您已经达到转生条件，您确定要进行第"
							+ (me.getLife_turn() + 1) + "次转生么?"));
					msgbox.setLeftName("确定");
					msgbox.setRightName("取消");
					msgbox.addLeftTLV(new ClearDataTLV());
					msgbox.addLeftTLV(new AddDataTLV((int) me.getRoleId()));
					msgbox.addLeftTLV(new SendDataTLV(MmochatConstant
							.getClientModuleId(),
							MmochatMain.getModuleInstID(),
							MmochatConstant.MSGCODE_MMOCHAT_C_9_23, (int) me
									.getSecond_role_type().getValue()));
					ShowWaitingMsgBoxTLV wait = new ShowWaitingMsgBoxTLV();
					wait.setShowCancel(false);
					msgbox.addLeftTLV(wait);
					tlv.addLeftTLV(msgbox);
				}
			}
			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		return MmochatUtil.msgbox(req.getHallState(), "暂无此功能!");
	}

	// 9.22 转生仙魔选择
	@SkymobiService
	public SkymobiProtocolMessage handleC_9_22(SkymobiHandler handler,
			Mmochat_9_22C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		Integer roleTypeValue = 0;
		try {
			roleTypeValue = Integer.parseInt(req.getRoleType());
		} catch (NumberFormatException e) {
			return MmochatUtil.msgbox(req.getHallState(), "只能输入数字1或2!");
		}
		if (roleTypeValue != 1 && roleTypeValue != 2) {
			return MmochatUtil.msgbox(req.getHallState(), "只能输入数字1或2!");
		}
		MmochatSecondRoleType roleType = MmochatSecondRoleType
				.get(roleTypeValue);
		if (roleType == null) {
			return MmochatUtil.msgbox(req.getHallState(), "只能输入数字1或2!");
		}

		CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
		msgbox.setContent(new Text("您确定要选择进入" + roleType.toString()
				+ "，并进行转生么?"));
		msgbox.setLeftName("确定");
		msgbox.setRightName("取消");
		msgbox.addLeftTLV(new ClearDataTLV());
		msgbox.addLeftTLV(new AddDataTLV((int) me.getRoleId()));
		msgbox.addLeftTLV(new SendDataTLV(MmochatConstant.getClientModuleId(),
				MmochatMain.getModuleInstID(),
				MmochatConstant.MSGCODE_MMOCHAT_C_9_23, (int) roleTypeValue));
		ShowWaitingMsgBoxTLV wait = new ShowWaitingMsgBoxTLV();
		wait.setShowCancel(false);
		msgbox.addLeftTLV(wait);
		return MmochatUtil.tlvResponse(req.getHallState(), msgbox);
	}

	// 9.23 开始转生
	@SkymobiService
	public SkymobiProtocolMessage handleC_9_23(SkymobiHandler handler,
			Mmochat_9_23C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}

		if (me.getLife_turn() >= MmochatConstant.maxLifeTurn) {
			return MmochatUtil.msgbox(req.getHallState(), "您已经达到最高转生次数，无法再转生!");
		} else {
			if (me.getLevel() != 129) {
				return MmochatUtil.msgbox(req.getHallState(), "您的等级未达到要求!");
			}

			if (me.getExp() < MmochatBattleService.getHumanExpNeedToUplevel(me
					.getLevel(), me.getLife_turn())) {
				return MmochatUtil.msgbox(req.getHallState(), "您的经验未达到要求!");
			}

			int daoNeed = MmochatBattleService.getStandardDao(129, me
					.getLife_turn()) * 2;
			if (me.getDao() < daoNeed) {
				return MmochatUtil.msgbox(req.getHallState(), "您的道行未达到要求!");
			}
		}
		MmochatSecondRoleType roleType = MmochatSecondRoleType.get(req
				.getRoleType());
		if (roleType == null) {
			return MmochatUtil.msgbox(req.getHallState(), "只能输入数字1或2!");
		}

		// 等级
		int oldLevel = me.getLevel();
		me.setLevel(MmochatConstant.levelAfterReborn);

		// 经验
		int oldExp = me.getExp();
		me.setExp(0);

		// 属性点
		int oldBloodPoint = me.getBlood_point();
		int oldSpritPoint = me.getSprit_point();
		int oldAttackPoint = me.getAttack_point();
		int oldSpeedPoint = me.getSpeed_point();
		int oldSpacePoint = me.getSpace_point();
		{
			int delBloodPoint = Math.max(0, me.getBlood_point()
					- MmochatConstant.levelAfterReborn);
			int delSpritPoint = Math.max(0, me.getSprit_point()
					- MmochatConstant.levelAfterReborn);
			int delAttackPoint = Math.max(0, me.getAttack_point()
					- MmochatConstant.levelAfterReborn);
			int delSpeedPoint = Math.max(0, me.getSpeed_point()
					- MmochatConstant.levelAfterReborn);
			me.delBlood_point(delBloodPoint);
			me.delSprit_point(delSpritPoint);
			me.delAttack_point(delAttackPoint);
			me.delSpeed_point(delSpeedPoint);
			me.addSpace_point(delBloodPoint + delSpritPoint + delAttackPoint
					+ delSpeedPoint);
			me.addSpace_point(8);
		}

		// 天赋点
		int oldBlood_giftPoint = me.getBlood_gift_point();
		int oldSprit_giftPoint = me.getSprit_gift_point();
		int oldAttack_giftPoint = me.getAttack_gift_point();
		int oldSpeed_giftPoint = me.getSpeed_gift_point();
		int oldSpace_giftPoint = me.getSpace_gift_point();
		{
			int delBloodPoint = me.getBlood_gift_point();
			int delSpritPoint = me.getSprit_gift_point();
			int delAttackPoint = me.getAttack_gift_point();
			int delSpeedPoint = me.getSpeed_gift_point();
			int delDefendPoint = me.getDefend_gift_point();

			me.delBlood_gift_point(delBloodPoint);
			me.delDefend_gift_point(delDefendPoint);
			me.delSprit_gift_point(delSpritPoint);
			me.delAttack_gift_point(delAttackPoint);
			me.delSpeed_gift_point(delSpeedPoint);
			me.addSpace_gift_point(delBloodPoint + delSpritPoint
					+ delAttackPoint + delSpeedPoint + delDefendPoint);
			me.addSpace_gift_point(1);
		}

		// 转生次数
		int oldLife_turn = me.getLife_turn();
		me.addLife_turn(1);

		// 仙魔属性
		MmochatSecondRoleType oldRoleType = me.getSecond_role_type();
		me.setSecond_role_type(roleType);

		// 保存数据库
		try {
			MmochatDao.reborn(me);
		} catch (Exception e) {
			e.printStackTrace();
			me.setLevel(oldLevel);
			me.setExp(oldExp);
			me.setBlood_point(oldBloodPoint);
			me.setSprit_point(oldSpritPoint);
			me.setAttack_point(oldAttackPoint);
			me.setSpeed_point(oldSpeedPoint);
			me.setSpace_point(oldSpacePoint);
			me.setBlood_gift_point(oldBlood_giftPoint);
			me.setSprit_gift_point(oldSprit_giftPoint);
			me.setAttack_gift_point(oldAttack_giftPoint);
			me.setSpeed_gift_point(oldSpeed_giftPoint);
			me.setSpace_gift_point(oldSpace_giftPoint);
			me.setLife_turn(oldLife_turn);
			me.setSecond_role_type(oldRoleType);
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙，请稍候再试!");
		}

		// 称号
		// 删除所有其它转生称号
		for (MmochatChenHaoType ctype : MmochatChenHaoType
				.getRebornChenhaoList()) {
			if (ctype != null) {
				MmochatChenHao.delAndUpdateChenHaoAndSaveSql(me.getRoleId(),
						ctype);
			}
		}
		// 设置新的转生称号
		MmochatChenHao chenhao = new MmochatChenHao();
		MmochatChenHaoType chenhaoType = MmochatChenHaoType.getChenhaoByReborn(
				me.getLife_turn(), me.getSecond_role_type());
		chenhao.setType(chenhaoType);
		MmochatEquipAttribute attr = new MmochatEquipAttribute();
		attr.setType(MmochatEquipAttributeType.全异常抵抗);
		attr.setValue(2 + me.getLife_turn() * 3);
		chenhao.addAttr(attr);

		attr = new MmochatEquipAttribute();
		attr.setType(MmochatEquipAttributeType.忽视全异常抵抗);
		attr.setValue(2 + me.getLife_turn() * 3);
		chenhao.addAttr(attr);
		MmochatChenHao.addAndUpdateChenHaoAndSaveSql(me.getRoleId(), chenhao);

		MmochatChatService.sendSystemMsg(MmochatUtil.wrapColor(me.getName(),
				Color.green)
				+ "修为达到上限，在掌门的帮助下实现了质的突破，完成了第" + me.getLife_turn() + "次转生。");
		return MmochatUtil.msgbox(req.getHallState(), MmochatUtil.wrapColor(
				"恭喜您，您已进阶到" + me.getLife_turn() + "转境界了。", Color.green));
	}

	// 9.24 查询试道王者
	@SkymobiService
	public SkymobiProtocolMessage handleC_9_24(SkymobiHandler handler,
			Mmochat_9_24C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		if (eventLogList == null) {
			return MmochatUtil.msgbox(req.getHallState(), "暂无数据!");
		}

		int level = req.getLevel();
		MmochatEventType eventType;
		switch (level) {
		case 30:
			eventType = MmochatEventType.武道会30级组;
			break;
		case 40:
			eventType = MmochatEventType.武道会40级组;
			break;
		case 50:
			eventType = MmochatEventType.武道会50级组;
			break;
		case 60:
			eventType = MmochatEventType.武道会60级组;
			break;
		case 70:
			eventType = MmochatEventType.武道会70级组;
			break;
		case 80:
			eventType = MmochatEventType.武道会80级组;
			break;
		case 90:
			eventType = MmochatEventType.武道会90级组;
			break;
		case 100:
			eventType = MmochatEventType.武道会100级组;
			break;
		case 110:
			eventType = MmochatEventType.武道会110级组;
			break;
		case 120:
			eventType = MmochatEventType.武道会120级组;
			break;
		default:
			eventType = MmochatEventType.武道会120级组;
			break;
		}

		CreateTlvWin tlv = new CreateTlvWin();
		tlv.setWinType(WinType.List);
		tlv.setLeftName("查看");
		tlv.setRightName("返回");
		tlv.setTitle(level + "级试道王者");
		tlv.setWinHeight(228);
		tlv.addRightTLV(new CloseWinTLV());

		SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
		for (MmochatEventLog eventLog : eventLogList) {
			if (eventLog.getType() == eventType) {
				String item = fmt.format(new Date(eventLog.getTime()));
				tlv.addItemEvent(item, new ClearDataTLV(), new AddDataTLV(
						(int) eventLog.getId()));
			}
		}
		tlv.addLeftTLV(new SendDataTLV(MmochatConstant.getClientModuleId(),
				MmochatMain.getModuleInstID(),
				MmochatConstant.MSGCODE_MMOCHAT_C_9_25, (int) req.getRoleId()));
		tlv.addLeftTLV(new ShowWaitingMsgBoxTLV());
		return MmochatUtil.tlvResponse(req.getHallState(), tlv);
	}

	// 9.25 查询试道王者
	@SkymobiService
	public SkymobiProtocolMessage handleC_9_25(SkymobiHandler handler,
			Mmochat_9_25C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		if (eventLogList == null) {
			return MmochatUtil.msgbox(req.getHallState(), "暂无数据!");
		}

		for (MmochatEventLog eventLog : eventLogList) {
			if (eventLog.getId() == req.getLogId()) {
				CreateTlvWin tlv = new CreateTlvWin();
				tlv.setWinType(WinType.Text);
				tlv.setRightName("返回");
				tlv.setTitle("试道王者");
				tlv.setWinHeight(228);
				tlv.addRightTLV(new CloseWinTLV());

				SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
				String content = MmochatUtil.wrapColor("时间\n", Color.yellow)
						+ fmt.format(new Date(eventLog.getTime())) + "\n\n";
				content += MmochatUtil.wrapColor("试道王者", Color.yellow);

				Gson gson = new Gson();
				List<String> nameList = gson.fromJson(eventLog.getContent(),
						new TypeToken<List<String>>() {
						}.getType());
				for (String name : nameList) {
					content += "\n" + name;
				}

				tlv.setContent(new Text(content));
				return MmochatUtil.tlvResponse(req.getHallState(), tlv);
			}
		}

		return MmochatUtil.msgbox(req.getHallState(), "暂无数据!");
	}

	// 9.26 查询出类拔萃者
	@SkymobiService
	public SkymobiProtocolMessage handleC_9_26(SkymobiHandler handler,
			Mmochat_9_26C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		if (eventLogList == null) {
			return MmochatUtil.msgbox(req.getHallState(), "暂无数据!");
		}

		int level = req.getLevel();
		MmochatEventType eventType;
		switch (level) {
		case 30:
			eventType = MmochatEventType.个人赛30级组;
			break;
		case 40:
			eventType = MmochatEventType.个人赛40级组;
			break;
		case 50:
			eventType = MmochatEventType.个人赛50级组;
			break;
		case 60:
			eventType = MmochatEventType.个人赛60级组;
			break;
		case 70:
			eventType = MmochatEventType.个人赛70级组;
			break;
		case 80:
			eventType = MmochatEventType.个人赛80级组;
			break;
		case 90:
			eventType = MmochatEventType.个人赛90级组;
			break;
		case 100:
			eventType = MmochatEventType.个人赛100级组;
			break;
		case 110:
			eventType = MmochatEventType.个人赛110级组;
			break;
		case 120:
			eventType = MmochatEventType.个人赛120级组;
			break;
		default:
			eventType = MmochatEventType.个人赛120级组;
			break;
		}

		CreateTlvWin tlv = new CreateTlvWin();
		tlv.setWinType(WinType.List);
		tlv.setRightName("返回");
		tlv.setTitle(level + "级出类拔萃");
		tlv.setWinHeight(228);
		tlv.addRightTLV(new CloseWinTLV());

		SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");

		Gson gson = new Gson();
		for (MmochatEventLog eventLog : eventLogList) {
			if (eventLog.getType() == eventType) {
				String item = fmt.format(new Date(eventLog.getTime()));
				List<String> nameList = gson.fromJson(eventLog.getContent(),
						new TypeToken<List<String>>() {
						}.getType());
				for (String name : nameList) {
					item += "\n" + MmochatUtil.wrapColor(name, Color.yellow);
				}
				tlv.addItemEvent(item);
			}
		}
		return MmochatUtil.tlvResponse(req.getHallState(), tlv);
	}

	// 9.27 查询帮派大战
	@SkymobiService
	public SkymobiProtocolMessage handleC_9_27(SkymobiHandler handler,
			Mmochat_9_27C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		if (eventLogList == null) {
			return MmochatUtil.msgbox(req.getHallState(), "暂无数据!");
		}

		for (MmochatEventLog eventLog : eventLogList) {
			if (eventLog.getId() == req.getLogId()) {
				CreateTlvWin tlv = new CreateTlvWin();
				tlv.setWinType(WinType.Text);
				tlv.setRightName("返回");
				tlv.setTitle("帮战前十");
				tlv.setWinHeight(228);
				tlv.addRightTLV(new CloseWinTLV());

				SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
				String content = MmochatUtil.wrapColor("时间\n", Color.yellow)
						+ fmt.format(new Date(eventLog.getTime())) + "\n\n";

				Gson gson = new Gson();
				List<String> nameList = gson.fromJson(eventLog.getContent(),
						new TypeToken<List<String>>() {
						}.getType());
				int index = 1;
				for (String name : nameList) {
					content += MmochatUtil.wrapColor("第" + index + "名：",
							Color.yellow);
					content += name + "\n";
					index++;
				}

				tlv.setContent(new Text(content));
				return MmochatUtil.tlvResponse(req.getHallState(), tlv);
			}
		}

		return MmochatUtil.msgbox(req.getHallState(), "暂无数据!");
	}

	// 9.28 查看转生装备满属
	@SkymobiService
	public SkymobiProtocolMessage handleC_9_28(SkymobiHandler handler,
			Mmochat_9_28C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		MmochatEquipType equipType = MmochatEquipType.get(req
				.getEquipTypeValue());
		if (equipType == null) {
			return MmochatUtil.msgbox(req.getHallState(), "暂无数据!");
		}
		List<MmochatEquipAttributeType> randAttrList = MmochatEquipService
				.getEquipRandAttributeTypesWithoutOverlap(equipType);
		if (randAttrList == null || randAttrList.size() == 0) {
			return MmochatUtil.msgbox(req.getHallState(), "没有附加属性!");
		}

		CreateTlvWin tlv = new CreateTlvWin();
		tlv.setWinType(WinType.List);
		tlv.setLeftName("查看");
		tlv.setRightName("返回");
		tlv.setTitle(equipType.toString());
		tlv.setWinHeight(208);
		tlv.addRightTLV(new CloseWinTLV());

		for (MmochatEquipAttributeType type : randAttrList) {
			tlv.addItemEvent(type.getStartInfo(), new ClearDataTLV(),
					new AddDataTLV((int) type.getValue()));
		}
		tlv.addLeftTLV(new AddDataTLV(req.getEquipTypeValue()));
		tlv.addLeftTLV(new SendDataTLV(MmochatConstant.getClientModuleId(),
				MmochatMain.getModuleInstID(),
				MmochatConstant.MSGCODE_MMOCHAT_C_9_29, (int) me.getRoleId()));
		tlv.addLeftTLV(new ShowWaitingMsgBoxTLV());

		return MmochatUtil.tlvResponse(req.getHallState(), tlv);
	}

	// 9.29 查看装备满属
	@SkymobiService
	public SkymobiProtocolMessage handleC_9_29(SkymobiHandler handler,
			Mmochat_9_29C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		MmochatEquipType equipType = MmochatEquipType.get(req
				.getEquipTypeValue());
		if (equipType == null) {
			return MmochatUtil.msgbox(req.getHallState(), "暂无数据!");
		}
		MmochatEquipAttributeType attrType = MmochatEquipAttributeType.get(req
				.getAttrTypeValue());
		if (attrType == null) {
			return MmochatUtil.msgbox(req.getHallState(), "暂无数据!");
		}

		Map<MmochatEquipAttributeType, Map<Integer, Integer[]>> m1 = MmochatEquipService.equipRandAttrData
				.get(equipType);
		if (m1 == null) {
			return MmochatUtil.msgbox(req.getHallState(), "暂无数据!");
		}
		Map<Integer, Integer[]> m2 = m1.get(attrType);
		if (m2 == null) {
			return MmochatUtil.msgbox(req.getHallState(), "暂无数据!");
		}

		List<MmochatEquipAttributeType> randAttrList = MmochatEquipService
				.getEquipAttributeTypes(equipType,
						MmochatEquipAttributeQualityType.附加属性);
		int overlapNum = 0;// 同一件装备中可出现的最大条数
		for (MmochatEquipAttributeType type : randAttrList) {
			if (type == attrType) {
				overlapNum++;
			}
		}

		CreateTlvWin tlv = new CreateTlvWin();
		tlv.setWinType(WinType.Text);
		tlv.setRightName("返回");
		tlv.setTitle(attrType.getStartInfo());
		tlv.setWinHeight(208);
		tlv.addRightTLV(new CloseWinTLV());
		String content = "";
		content += MmochatUtil.wrapColor(
				"同一件装备中最多允许出现" + overlapNum + "条此属性\n", Color.magenta);

		for (int i = 1; i <= MmochatConstant.maxLifeTurn; i++) {
			int level = 120 + i * 10;
			Integer[] m3 = m2.get(level);
			if (m3 != null) {
				content += "\n"
						+ MmochatUtil.wrapColor("[" + i + "转"
								+ equipType.toString() + "]", Color.yellow)
						+ "\n";
				content += "最小属性值:" + m3[0] + "\n";
				content += "最大属性值:" + m3[1] + "\n";
			}
		}
		tlv.setContent(new Text(content));
		return MmochatUtil.tlvResponse(req.getHallState(), tlv);
	}

	// 9.30 人物仙魔转换
	@SkymobiService
	public SkymobiProtocolMessage handleC_9_30(SkymobiHandler handler,
			Mmochat_9_30C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		if (me.getLife_turn() == 0) {
			return MmochatUtil.msgbox(req.getHallState(), "您尚未转生，无法进行仙魔转换!");
		}
		MmochatSecondRoleType newType = null;
		switch (me.getSecond_role_type()) {
		case 仙道:
			newType = MmochatSecondRoleType.魔道;
			break;
		case 魔道:
			newType = MmochatSecondRoleType.仙道;
			break;
		case 未转生:
		default:
			return MmochatUtil.msgbox(req.getHallState(), "您尚未转生，无法进行仙魔转换!");
		}
		if (me.getBig_money() < MmochatConstant.bigmoneyNeedToChangSecondRoleType) {
			return MmochatUtil.msgbox(req.getHallState(), "您的元宝不足!");
		}

		// 装备必须卸下
		MmochatPackageGrid grid1 = me.getMyPackage().get(
				MmochatEquipPlaceType.头部.getValue());
		if (grid1 != null && grid1.hasObj()) {
			return MmochatUtil.msgbox(req.getHallState(),
					"请先将武器、头盔、衣服、鞋子卸下来，再进行仙魔转换!");
		}
		grid1 = me.getMyPackage().get(MmochatEquipPlaceType.手上.getValue());
		if (grid1 != null && grid1.hasObj()) {
			return MmochatUtil.msgbox(req.getHallState(),
					"请先将武器、头盔、衣服、鞋子卸下来，再进行仙魔转换!");
		}
		grid1 = me.getMyPackage().get(MmochatEquipPlaceType.身体.getValue());
		if (grid1 != null && grid1.hasObj()) {
			return MmochatUtil.msgbox(req.getHallState(),
					"请先将武器、头盔、衣服、鞋子卸下来，再进行仙魔转换!");
		}
		grid1 = me.getMyPackage().get(MmochatEquipPlaceType.脚.getValue());
		if (grid1 != null && grid1.hasObj()) {
			return MmochatUtil.msgbox(req.getHallState(),
					"请先将武器、头盔、衣服、鞋子卸下来，再进行仙魔转换!");
		}

		// 开始转换
		long oldLimit = me.getLimit_bigmoney();
		me.addLimit_bigmoney(-1
				* MmochatConstant.bigmoneyNeedToChangSecondRoleType);
		try {
			MmochatDao.changSecondRoleType(newType,
					MmochatConstant.bigmoneyNeedToChangSecondRoleType, me
							.getLimit_bigmoney(), me.getRoleId());
		} catch (Exception e) {
			e.printStackTrace();
			me.setLimit_bigmoney(oldLimit);
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		MmochatStatisticsService.todayBigMoneyCost += MmochatConstant.bigmoneyNeedToChangSecondRoleType;
		me.setSecond_role_type(newType);
		me.addBig_money(-1 * MmochatConstant.bigmoneyNeedToChangSecondRoleType);

		// 称号
		// 删除所有其它转生称号
		for (MmochatChenHaoType ctype : MmochatChenHaoType
				.getRebornChenhaoList()) {
			if (ctype != null) {
				MmochatChenHao.delAndUpdateChenHaoAndSaveSql(me.getRoleId(),
						ctype);
			}
		}
		// 设置新的转生称号
		MmochatChenHao chenhao = new MmochatChenHao();
		MmochatChenHaoType chenhaoType = MmochatChenHaoType.getChenhaoByReborn(
				me.getLife_turn(), me.getSecond_role_type());
		chenhao.setType(chenhaoType);
		MmochatEquipAttribute attr = new MmochatEquipAttribute();
		attr.setType(MmochatEquipAttributeType.全异常抵抗);
		attr.setValue(2 + me.getLife_turn() * 3);
		chenhao.addAttr(attr);

		attr = new MmochatEquipAttribute();
		attr.setType(MmochatEquipAttributeType.忽视全异常抵抗);
		attr.setValue(2 + me.getLife_turn() * 3);
		chenhao.addAttr(attr);
		MmochatChenHao.addAndUpdateChenHaoAndSaveSql(me.getRoleId(), chenhao);

		return MmochatUtil
				.msgbox(req.getHallState(), "转换成功，您已改换门庭，进入"
						+ MmochatUtil.wrapColor(newType.toString(),
								Color.yellow) + "!");
	}

	// 9.31 开始宠物转生
	@SkymobiService
	public SkymobiProtocolMessage handleC_9_31(SkymobiHandler handler,
			Mmochat_9_31C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}

		MmochatPet pet = me.getPkPet();
		if (pet == null) {
			return MmochatUtil.msgbox(req.getHallState(), "请将需要转生的宠物设置为参战!");
		}

		if (pet.getLife_turn() >= MmochatConstant.maxLifeTurn) {
			return MmochatUtil.msgbox(req.getHallState(),
					"您的宠物已经达到最高转生次数，无法再转生!");
		} else {
			if (pet.getLevel() != 129) {
				return MmochatUtil.msgbox(req.getHallState(), "您的宠物等级未达到要求!");
			}

			if (pet.getExp() < MmochatBattleService.getPetExpNeedToUplevel(pet
					.getLevel(), pet.getLife_turn())) {
				return MmochatUtil.msgbox(req.getHallState(), "您的宠物经验未达到要求!");
			}

			if (pet.getPetType() == MmochatPetType.野生) {
				return MmochatUtil.msgbox(req.getHallState(), "野生宠物无法转生!");
			}
		}

		// 等级
		int oldLevel = pet.getLevel();
		pet.setLevel(MmochatConstant.levelAfterReborn);

		// 经验
		int oldExp = pet.getExp();
		pet.setExp(0);

		// 属性点
		int oldBloodPoint = pet.getBlood_point();
		int oldSpritPoint = pet.getSprit_point();
		int oldAttackPoint = pet.getAttack_point();
		int oldSpeedPoint = pet.getSpeed_point();
		int oldSpacePoint = pet.getSpace_point();
		{
			int delBloodPoint = Math.max(0, pet.getBlood_point()
					- MmochatConstant.levelAfterReborn);
			int delSpritPoint = Math.max(0, pet.getSprit_point()
					- MmochatConstant.levelAfterReborn);
			int delAttackPoint = Math.max(0, pet.getAttack_point()
					- MmochatConstant.levelAfterReborn);
			int delSpeedPoint = Math.max(0, pet.getSpeed_point()
					- MmochatConstant.levelAfterReborn);
			pet.delBlood_point(delBloodPoint);
			pet.delSprit_point(delSpritPoint);
			pet.delAttack_point(delAttackPoint);
			pet.delSpeed_point(delSpeedPoint);
			pet.addSpace_point(delBloodPoint + delSpritPoint + delAttackPoint
					+ delSpeedPoint);
			pet.addSpace_point(8);
		}

		// 转生次数
		int oldLife_turn = pet.getLife_turn();
		pet.addLife_turn(1);

		// 保存数据库
		try {
			MmochatDao.updateRolePets(me);
		} catch (Exception e) {
			e.printStackTrace();
			pet.setLevel(oldLevel);
			pet.setExp(oldExp);
			pet.setBlood_point(oldBloodPoint);
			pet.setSprit_point(oldSpritPoint);
			pet.setAttack_point(oldAttackPoint);
			pet.setSpeed_point(oldSpeedPoint);
			pet.setSpace_point(oldSpacePoint);
			pet.setLife_turn(oldLife_turn);
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙，请稍候再试!");
		}

		return MmochatUtil.msgbox(req.getHallState(), MmochatUtil.wrapColor(
				"恭喜，您的爱宠" + MmochatUtil.wrapColor(pet.getName(), Color.yellow)
						+ "已进阶到" + pet.getLife_turn() + "转境界了。", Color.green));
	}

	// 9.32 查询跨服试道王者
	@SkymobiService
	public SkymobiProtocolMessage handleC_9_32(SkymobiHandler handler,
			Mmochat_9_32C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		if (eventLogList == null) {
			return MmochatUtil.msgbox(req.getHallState(), "暂无数据!");
		}

		int level = req.getLevel();
		MmochatEventType eventType;
		switch (level) {
		case 30:
			eventType = MmochatEventType.跨服武道会30级组;
			break;
		case 40:
			eventType = MmochatEventType.跨服武道会40级组;
			break;
		case 50:
			eventType = MmochatEventType.跨服武道会50级组;
			break;
		case 60:
			eventType = MmochatEventType.跨服武道会60级组;
			break;
		case 70:
			eventType = MmochatEventType.跨服武道会70级组;
			break;
		case 80:
			eventType = MmochatEventType.跨服武道会80级组;
			break;
		case 90:
			eventType = MmochatEventType.跨服武道会90级组;
			break;
		case 100:
			eventType = MmochatEventType.跨服武道会100级组;
			break;
		case 110:
			eventType = MmochatEventType.跨服武道会110级组;
			break;
		case 120:
			eventType = MmochatEventType.跨服武道会120级组;
			break;
		default:
			eventType = MmochatEventType.跨服武道会120级组;
			break;
		}

		CreateTlvWin tlv = new CreateTlvWin();
		tlv.setWinType(WinType.List);
		tlv.setLeftName("查看");
		tlv.setRightName("返回");
		tlv.setTitle(level + "级跨服道王");
		tlv.setWinHeight(228);
		tlv.addRightTLV(new CloseWinTLV());

		SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
		for (MmochatEventLog eventLog : eventLogList) {
			if (eventLog.getType() == eventType) {
				String item = fmt.format(new Date(eventLog.getTime()));
				tlv.addItemEvent(item, new ClearDataTLV(), new AddDataTLV(
						(int) eventLog.getId()));
			}
		}
		tlv.addLeftTLV(new SendDataTLV(MmochatConstant.getClientModuleId(),
				MmochatMain.getModuleInstID(),
				MmochatConstant.MSGCODE_MMOCHAT_C_9_33, (int) req.getRoleId()));
		tlv.addLeftTLV(new ShowWaitingMsgBoxTLV());
		return MmochatUtil.tlvResponse(req.getHallState(), tlv);
	}

	// 9.33查询跨服试道王者
	@SkymobiService
	public SkymobiProtocolMessage handleC_9_33(SkymobiHandler handler,
			Mmochat_9_33C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		if (eventLogList == null) {
			return MmochatUtil.msgbox(req.getHallState(), "暂无数据!");
		}

		for (MmochatEventLog eventLog : eventLogList) {
			if (eventLog.getId() == req.getLogId()) {
				CreateTlvWin tlv = new CreateTlvWin();
				tlv.setWinType(WinType.Text);
				tlv.setRightName("返回");
				tlv.setTitle("跨服试道王者");
				tlv.setWinHeight(228);
				tlv.addRightTLV(new CloseWinTLV());

				SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
				String content = MmochatUtil.wrapColor("时间\n", Color.yellow)
						+ fmt.format(new Date(eventLog.getTime())) + "\n\n";
				content += MmochatUtil.wrapColor("跨服试道王者", Color.yellow);

				content += "\n"
						+ MmochatUtil.wrapColor(eventLog.getTitle(),
								Color.magenta) + "\n";
				content += eventLog.getContent();

				tlv.setContent(new Text(content));
				return MmochatUtil.tlvResponse(req.getHallState(), tlv);
			}
		}

		return MmochatUtil.msgbox(req.getHallState(), "暂无数据!");
	}

	// 声望竞猜界面
	private CreateTlvWin getHonorGameTlv(MmochatPlayer me) {
		CreateTlvWin tlv = new CreateTlvWin();
		tlv.setWinType(WinType.Text);
		tlv.setLeftName("竞猜");
		tlv.setRightName("返回");
		tlv.setTitle("威望竞猜");
		tlv.setWinHeight(188);
		tlv.setWinId(MmochatConstant.TLV_WIN_HONOR);
		tlv.addRightTLV(new CloseWinTLV(MmochatConstant.TLV_WIN_HONOR));

		long moneyNeed = MmochatConstant.moneyParamForHonorGame * me.getHonor();
		String content = "";
		content += MmochatUtil.wrapColor("[我的威望]", Color.yellow);
		content += "\n" + me.getHonor() + "点\n\n";
		content += MmochatUtil.wrapColor("[玩法介绍]", Color.yellow);
		content += "\n按竞猜按钮后，需要扣除" + MmochatUtil.getColorMoney(moneyNeed)
				+ "文钱，有三分之一机率使威望翻倍，有三分之二机率使威望减半。";
		tlv.setContent(new Text(content));

		if (me.getHonor() <= 0) {
			CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
			msgbox.setContent(new Text("您的威望不足1点，无法竞猜!"));
			msgbox.setLeftName("确定");
			tlv.addLeftTLV(msgbox);
		} else if (me.getSmall_money() < moneyNeed) {
			CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
			msgbox.setContent(new Text("您的金钱不足" + moneyNeed + "文，无法竞猜!"));
			msgbox.setLeftName("确定");
			tlv.addLeftTLV(msgbox);
		} else {
			CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
			String hint = "您确定要竞猜么?有三分之一机率威望翻倍，有三分之二机率威望减半!";
			msgbox.setContent(new Text(hint));
			msgbox.setLeftName("确定");
			msgbox.setRightName("取消");

			msgbox.addLeftTLV(new ClearDataTLV());
			msgbox.addLeftTLV(new AddDataTLV((int) me.getRoleId()));
			msgbox.addLeftTLV(new SendDataTLV(MmochatConstant
					.getClientModuleId(), MmochatMain.getModuleInstID(),
					MmochatConstant.MSGCODE_MMOCHAT_C_9_40, null));
			ShowWaitingMsgBoxTLV wait = new ShowWaitingMsgBoxTLV();
			wait.setShowCancel(false);
			msgbox.addLeftTLV(wait);

			tlv.addLeftTLV(msgbox);
		}
		return tlv;
	}

	// 9.34 威望兑换
	@SkymobiService
	public SkymobiProtocolMessage handleC_9_34(SkymobiHandler handler,
			Mmochat_9_34C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		switch (req.getIndex()) {
		case 1: {
			// 查看我的威望
			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinType(WinType.Text);
			tlv.setRightName("返回");
			tlv.setTitle("我的威望");
			tlv.setWinHeight(188);
			tlv.addRightTLV(new CloseWinTLV());

			String content = "";
			content += MmochatUtil.wrapColor("[我的威望]", Color.yellow);
			content += "\n" + me.getHonor() + "点\n\n";
			content += MmochatUtil.wrapColor("[威望的获得]", Color.yellow);
			content += "\n威望可以在跨服武道大会等比赛中获得。";
			tlv.setContent(new Text(content));
			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		case 2: {
			// 兑换经验
			Map<MmochatRoleAttributeType, Double> attrMap = MmochatPetService.monsterBaseAttackData
					.get(me.getTrueLevel());
			int exp = 0;
			if (attrMap != null) {
				exp = (int) (attrMap.get(MmochatRoleAttributeType.杀死怪物经验) * MmochatConstant.expParamPerHonor);
			} else {
				return MmochatUtil
						.msgbox(req.getHallState(), "按您的等级，目前无法兑换经验!");
			}

			String content = "您当前有"
					+ MmochatUtil.wrapColor(me.getHonor(), Color.magenta)
					+ "点威望!";
			content += "\n按您的等级，1点威望可以兑换"
					+ MmochatUtil.wrapColor(exp, Color.green) + "点经验!";
			content += "请输入您要兑换的威望数!";
			CreateEditBoxTLV edit = new CreateEditBoxTLV();
			edit.setTitle(content);
			edit.setLeftName("兑换");
			edit.setRightName("取消");
			edit.setContentLenMax(4);
			edit.setBoxType(CreateEditBoxTLV.TYPE_MSGBOX);
			edit.setInputType(CreateEditBoxTLV.INPUT_NUM << 4);
			edit.addLeftTLV(new ClearDataTLV());
			edit.addLeftTLV(new AddDataTLV((int) me.getRoleId()));
			edit.addLeftTLV(new AddEditBoxTLV());
			edit.addLeftTLV(new SendDataTLV(
					MmochatConstant.getClientModuleId(), MmochatMain
							.getModuleInstID(),
					MmochatConstant.MSGCODE_MMOCHAT_C_9_35, null));
			ShowWaitingMsgBoxTLV wait = new ShowWaitingMsgBoxTLV();
			wait.setShowCancel(false);
			edit.addLeftTLV(wait);
			return MmochatUtil.tlvResponse(req.getHallState(), edit);
		}
		case 3: {
			// 兑换道行
			int dao = (int) MmochatConstant.daoParamPerHonor;

			String content = "您当前有"
					+ MmochatUtil.wrapColor(me.getHonor(), Color.magenta)
					+ "点威望!";
			content += "\n1点威望可以兑换" + MmochatUtil.wrapColor(dao, Color.green)
					+ "天道行(如果人物高于标准道行，实际奖励会相应削减)!";
			content += "请输入您要兑换的威望数!";
			CreateEditBoxTLV edit = new CreateEditBoxTLV();
			edit.setTitle(content);
			edit.setLeftName("兑换");
			edit.setRightName("取消");
			edit.setContentLenMax(3);
			edit.setBoxType(CreateEditBoxTLV.TYPE_MSGBOX);
			edit.setInputType(CreateEditBoxTLV.INPUT_NUM << 4);
			edit.addLeftTLV(new ClearDataTLV());
			edit.addLeftTLV(new AddDataTLV((int) me.getRoleId()));
			edit.addLeftTLV(new AddEditBoxTLV());
			edit.addLeftTLV(new SendDataTLV(
					MmochatConstant.getClientModuleId(), MmochatMain
							.getModuleInstID(),
					MmochatConstant.MSGCODE_MMOCHAT_C_9_36, null));
			ShowWaitingMsgBoxTLV wait = new ShowWaitingMsgBoxTLV();
			wait.setShowCancel(false);
			edit.addLeftTLV(wait);
			return MmochatUtil.tlvResponse(req.getHallState(), edit);
		}
		case 4: {
			// 兑换金钱袋
			String content = "您当前有"
					+ MmochatUtil.wrapColor(me.getHonor(), Color.magenta)
					+ "点威望!";
			content += "\n" + MmochatConstant.honorNumPerMoneyProp
					+ "点威望可以兑换1个金钱袋!您确定要兑换么?";
			CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
			msgbox.setContent(new Text(content));
			msgbox.setLeftName("兑换");
			msgbox.setRightName("取消");

			msgbox.addLeftTLV(new ClearDataTLV());
			msgbox.addLeftTLV(new AddDataTLV((int) me.getRoleId()));
			msgbox.addLeftTLV(new SendDataTLV(MmochatConstant
					.getClientModuleId(), MmochatMain.getModuleInstID(),
					MmochatConstant.MSGCODE_MMOCHAT_C_9_37, null));
			ShowWaitingMsgBoxTLV wait = new ShowWaitingMsgBoxTLV();
			wait.setShowCancel(false);
			msgbox.addLeftTLV(wait);
			return MmochatUtil.tlvResponse(req.getHallState(), msgbox);
		}
		case 5: {
			// 兑换神兽
			String content = "您当前有"
					+ MmochatUtil.wrapColor(me.getHonor(), Color.magenta)
					+ "点威望!";
			content += "\n" + MmochatConstant.honorNumPerPet
					+ "点威望可以兑换1个随机类型的神兽!您确定要兑换么?";
			CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
			msgbox.setContent(new Text(content));
			msgbox.setLeftName("兑换");
			msgbox.setRightName("取消");

			msgbox.addLeftTLV(new ClearDataTLV());
			msgbox.addLeftTLV(new AddDataTLV((int) me.getRoleId()));
			msgbox.addLeftTLV(new SendDataTLV(MmochatConstant
					.getClientModuleId(), MmochatMain.getModuleInstID(),
					MmochatConstant.MSGCODE_MMOCHAT_C_9_38, null));
			ShowWaitingMsgBoxTLV wait = new ShowWaitingMsgBoxTLV();
			wait.setShowCancel(false);
			msgbox.addLeftTLV(wait);
			return MmochatUtil.tlvResponse(req.getHallState(), msgbox);
		}
		case 6: {
			// 兑换8级浮云
			String content = "您当前有"
					+ MmochatUtil.wrapColor(me.getHonor(), Color.magenta)
					+ "点威望!";
			content += "\n" + MmochatConstant.honorNumPerFly
					+ "点威望可以兑换1个8级神行法宝!您确定要兑换么?";
			CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
			msgbox.setContent(new Text(content));
			msgbox.setLeftName("兑换");
			msgbox.setRightName("取消");

			msgbox.addLeftTLV(new ClearDataTLV());
			msgbox.addLeftTLV(new AddDataTLV((int) me.getRoleId()));
			msgbox.addLeftTLV(new SendDataTLV(MmochatConstant
					.getClientModuleId(), MmochatMain.getModuleInstID(),
					MmochatConstant.MSGCODE_MMOCHAT_C_9_39, null));
			ShowWaitingMsgBoxTLV wait = new ShowWaitingMsgBoxTLV();
			wait.setShowCancel(false);
			msgbox.addLeftTLV(wait);
			return MmochatUtil.tlvResponse(req.getHallState(), msgbox);
		}
		case 7: {
			// 威望竞猜
			CreateTlvWin tlv = getHonorGameTlv(me);
			return MmochatUtil.tlvResponse(req.getHallState(), new CloseWinTLV(
					MmochatConstant.TLV_WIN_HONOR), tlv);
		}
		case 8: {
			// 威望抽奖
			String content = "您当前有"
					+ MmochatUtil.wrapColor(me.getHonor(), Color.magenta)
					+ "点威望!";
			content += "\n" + MmochatConstant.honorNumPerRandAward
					+ "点威望可以抽一次奖。奖励列表:" + "白娘子(变异)、1-5星武魂、武魂石、武魂石灵气珠、商城道具、战绩!";
			CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
			msgbox.setContent(new Text(content));
			msgbox.setLeftName("抽奖");
			msgbox.setRightName("取消");

			msgbox.addLeftTLV(new ClearDataTLV());
			msgbox.addLeftTLV(new AddDataTLV((int) me.getRoleId()));
			msgbox.addLeftTLV(new SendDataTLV(MmochatConstant
					.getClientModuleId(), MmochatMain.getModuleInstID(),
					MmochatConstant.MSGCODE_MMOCHAT_C_9_64, null));
			ShowWaitingMsgBoxTLV wait = new ShowWaitingMsgBoxTLV();
			wait.setShowCancel(false);
			msgbox.addLeftTLV(wait);
			return MmochatUtil.tlvResponse(req.getHallState(), msgbox);
		}
		default:
			break;
		}

		return null;
	}

	// 9.35 威望兑换经验
	@SkymobiService
	public SkymobiProtocolMessage handleC_9_35(SkymobiHandler handler,
			Mmochat_9_35C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		int honorToChange = 0;
		try {
			honorToChange = Integer.parseInt(req.getNumStr());
		} catch (NumberFormatException e) {
			return MmochatUtil.msgbox(req.getHallState(), "只能输入数字!");
		}
		if (honorToChange <= 0) {
			return MmochatUtil.msgbox(req.getHallState(), "只能输入大于0的数字!");
		}
		if (honorToChange > 9999) {
			return MmochatUtil.msgbox(req.getHallState(), "只能输入小于10000的数字!");
		}
		if (me.getHonor() < honorToChange) {
			return MmochatUtil.msgbox(req.getHallState(), "您的威望不足"
					+ honorToChange + "点!");
		}
		// 开始兑换
		int exp = 0;
		Map<MmochatRoleAttributeType, Double> attrMap = MmochatPetService.monsterBaseAttackData
				.get(me.getTrueLevel());
		if (attrMap != null) {
			exp = (int) (attrMap.get(MmochatRoleAttributeType.杀死怪物经验) * MmochatConstant.expParamPerHonor);
		} else {
			return MmochatUtil.msgbox(req.getHallState(), "按您的等级，目前无法兑换经验!");
		}
		long expAward = (long) exp * honorToChange;

		synchronized (me) {
			if (me.getHonor() < honorToChange) {
				return MmochatUtil.msgbox(req.getHallState(), "您的威望不足"
						+ honorToChange + "点!");
			}
			me.addHonor(-1 * honorToChange);
			int oldExp = me.getExp();
			int oldLevel = me.getLevel();
			boolean uplevel = me.addExp(expAward);
			try {
				MmochatDao.saveHonorExpDao(me);
			} catch (Exception e) {
				e.printStackTrace();
				me.addHonor(honorToChange);
				me.setExp(oldExp);
				me.setLevel(oldLevel);
				return MmochatUtil.msgbox(req.getHallState(), "服务器忙，请稍候再试!");
			}
			// 更新头像图标信息
			Mmochat_1_7S pack = new Mmochat_1_7S(uplevel);
			pack.setMe(me);
			MmochatUtil.sendCommonPack(me, pack);
			String info = "兑换成功!您获得了"
					+ MmochatUtil.wrapColor(expAward, Color.green)
					+ "点经验!您当前剩余威望" + me.getHonor() + "点";
			MmochatChatService.sendSystemMsgToPerson(me, info);
			info = MmochatUtil.wrapColor(info, Color.yellow);
			return MmochatUtil.msgbox(req.getHallState(), info);
		}
	}

	// 9.36 威望兑换道行
	@SkymobiService
	public SkymobiProtocolMessage handleC_9_36(SkymobiHandler handler,
			Mmochat_9_36C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		int honorToChange = 0;
		try {
			honorToChange = Integer.parseInt(req.getNumStr());
		} catch (NumberFormatException e) {
			return MmochatUtil.msgbox(req.getHallState(), "只能输入数字!");
		}
		if (honorToChange < 10) {
			return MmochatUtil.msgbox(req.getHallState(), "每次至少兑换10点威望!");
		}
		if (honorToChange > 999) {
			return MmochatUtil.msgbox(req.getHallState(), "一次最多兑换999点威望!");
		}
		if (me.getHonor() < honorToChange) {
			return MmochatUtil.msgbox(req.getHallState(), "您的威望不足"
					+ honorToChange + "点!");
		}
		// 开始兑换
		int dao = (int) MmochatConstant.daoParamPerHonor;
		long daoAward = (long) dao * honorToChange;
		int realDao = MmochatBattleService.getRealDao(me, daoAward);

		synchronized (me) {
			if (me.getHonor() < honorToChange) {
				return MmochatUtil.msgbox(req.getHallState(), "您的威望不足"
						+ honorToChange + "点!");
			}
			me.addHonor(-1 * honorToChange);
			me.addDao(realDao);
			// 刷道比赛
			MmochatPropService.dealDaoActivity(me, (int) daoAward);

			try {
				MmochatDao.saveHonorExpDao(me);
			} catch (Exception e) {
				e.printStackTrace();
				me.addHonor(honorToChange);
				me.addDao(-1 * realDao);
				return MmochatUtil.msgbox(req.getHallState(), "服务器忙，请稍候再试!");
			}
			String info = "兑换成功!您获得了"
					+ MmochatUtil.wrapColor(realDao, Color.green) + "天道行(削减前"
					+ daoAward + "天)!您当前剩余威望" + me.getHonor() + "点";
			MmochatChatService.sendSystemMsgToPerson(me, info);
			info = MmochatUtil.wrapColor(info, Color.yellow);
			return MmochatUtil.msgbox(req.getHallState(), info);
		}
	}

	// 9.37 威望兑换金钱袋
	@SkymobiService
	public SkymobiProtocolMessage handleC_9_37(SkymobiHandler handler,
			Mmochat_9_37C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}

		if (me.getHonor() < MmochatConstant.honorNumPerMoneyProp) {
			return MmochatUtil.msgbox(req.getHallState(), "您的威望不足"
					+ MmochatConstant.honorNumPerMoneyProp + "点!");
		}
		if (!me.hasEnoughPackageSpace(1)) {
			return MmochatUtil.msgbox(req.getHallState(), "您的包裹已满，请先清理出一个空位!");
		}
		// 开始兑换
		synchronized (me) {
			if (me.getHonor() < MmochatConstant.honorNumPerMoneyProp) {
				return MmochatUtil.msgbox(req.getHallState(), "您的威望不足"
						+ MmochatConstant.honorNumPerMoneyProp + "点!");
			}
			if (!me.hasEnoughPackageSpace(1)) {
				return MmochatUtil.msgbox(req.getHallState(),
						"您的包裹已满，请先清理出一个空位!");
			}
			me.addHonor(-1 * MmochatConstant.honorNumPerMoneyProp);
			MmochatProp prop = new MmochatProp(MmochatPropType.金钱袋);
			me.addObjectToPackage(prop);
			try {
				MmochatDao.saveHonorAndPackage(me);
			} catch (Exception e) {
				e.printStackTrace();
				me.addHonor(MmochatConstant.honorNumPerMoneyProp);
				me.delPackageObj(MmochatPropType.金钱袋, 1);
				return MmochatUtil.msgbox(req.getHallState(), "服务器忙，请稍候再试!");
			}
			String info = "兑换成功!您获得了1个金钱袋!您当前剩余威望" + me.getHonor() + "点";
			MmochatChatService.sendSystemMsgToPerson(me, info);
			info = MmochatUtil.wrapColor(info, Color.yellow);
			return MmochatUtil.msgbox(req.getHallState(), info);
		}
	}

	// 9.38 威望兑换神兽
	@SkymobiService
	public SkymobiProtocolMessage handleC_9_38(SkymobiHandler handler,
			Mmochat_9_38C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}

		if (me.getHonor() < MmochatConstant.honorNumPerPet) {
			return MmochatUtil.msgbox(req.getHallState(), "您的威望不足"
					+ MmochatConstant.honorNumPerPet + "点!");
		}
		if (me.isPetFull()) {
			return MmochatUtil.msgbox(req.getHallState(),
					"您携带的宠物数量已达上限，请先存放到仓库再来兑换!");
		}
		// 开始兑换
		synchronized (me) {
			if (me.getHonor() < MmochatConstant.honorNumPerPet) {
				return MmochatUtil.msgbox(req.getHallState(), "您的威望不足"
						+ MmochatConstant.honorNumPerPet + "点!");
			}
			if (me.isPetFull()) {
				return MmochatUtil.msgbox(req.getHallState(),
						"您携带的宠物数量已达上限，请先存放到仓库再来兑换!");
			}
			me.addHonor(-1 * MmochatConstant.honorNumPerPet);

			MmochatRoleType[] list = new MmochatRoleType[] {
					MmochatRoleType.高力玄武, MmochatRoleType.通灵玄武,
					MmochatRoleType.铁血玄武, MmochatRoleType.幻影玄武 };
			int itemIndex = MmochatUtil.getRandomValue(list.length);
			MmochatRoleType type = list[itemIndex];
			MmochatPet pet = MmochatPetService.createPetByType(type);
			me.addPet(pet);
			try {
				MmochatDao.saveHonorAndPets(me);
			} catch (Exception e) {
				e.printStackTrace();
				me.addHonor(MmochatConstant.honorNumPerPet);
				me.delPet(pet.getId());
				return MmochatUtil.msgbox(req.getHallState(), "服务器忙，请稍候再试!");
			}
			String info = "兑换成功!您获得了1个" + type.toString() + "!您当前剩余威望"
					+ me.getHonor() + "点";
			MmochatChatService.sendSystemMsgToPerson(me, info);
			info = MmochatUtil.wrapColor(info, Color.yellow);
			return MmochatUtil.msgbox(req.getHallState(), info);
		}
	}

	// 9.39 威望兑换浮云
	@SkymobiService
	public SkymobiProtocolMessage handleC_9_39(SkymobiHandler handler,
			Mmochat_9_39C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}

		if (me.getHonor() < MmochatConstant.honorNumPerFly) {
			return MmochatUtil.msgbox(req.getHallState(), "您的威望不足"
					+ MmochatConstant.honorNumPerFly + "点!");
		}
		if (!me.hasEnoughPackageSpace(1)) {
			return MmochatUtil.msgbox(req.getHallState(), "您的包裹已满，请先清理出一个空位!");
		}
		// 开始兑换
		synchronized (me) {
			if (me.getHonor() < MmochatConstant.honorNumPerFly) {
				return MmochatUtil.msgbox(req.getHallState(), "您的威望不足"
						+ MmochatConstant.honorNumPerFly + "点!");
			}
			if (!me.hasEnoughPackageSpace(1)) {
				return MmochatUtil.msgbox(req.getHallState(),
						"您的包裹已满，请先清理出一个空位!");
			}
			me.addHonor(-1 * MmochatConstant.honorNumPerFly);

			MmochatCommonObject obj = new MmochatSuperMachine(
					MmochatSuperMachineType.神行法宝);
			obj.setCanDeal(true);
			obj.setOverlapNum(1);
			obj
					.setFlyMachineSpeedLevel(MmochatCommonObject.flyMachineMaxSpeedLevel);
			obj
					.setFlyMachineFlyLevel(MmochatCommonObject.flyMachineMaxFlyLevel);
			obj.setFlyMachineCanUseTotalValue(3000);
			obj.setFlyMachineCanUseValue(3000);
			me.addObjectToPackage(obj);

			try {
				MmochatDao.saveHonorAndPackage(me);
			} catch (Exception e) {
				e.printStackTrace();
				me.addHonor(MmochatConstant.honorNumPerFly);
				me.delPackageObjById(obj.getId());
				return MmochatUtil.msgbox(req.getHallState(), "服务器忙，请稍候再试!");
			}
			String info = "兑换成功!您获得了1个8级浮云!您当前剩余威望" + me.getHonor() + "点";
			MmochatChatService.sendSystemMsgToPerson(me, info);
			info = MmochatUtil.wrapColor(info, Color.yellow);
			return MmochatUtil.msgbox(req.getHallState(), info);
		}
	}

	// 9.40 威望竞猜
	@SkymobiService
	public SkymobiProtocolMessage handleC_9_40(SkymobiHandler handler,
			Mmochat_9_40C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		if (me.getHonor() <= 0) {
			CreateTlvWin tlv = getHonorGameTlv(me);
			CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
			msgbox.setContent(new Text("您的威望不足1点!"));
			msgbox.setLeftName("确定");
			return MmochatUtil.tlvResponse(req.getHallState(), new CloseWinTLV(
					MmochatConstant.TLV_WIN_HONOR), tlv, msgbox);
		}
		int moneyNeed = (int) Math.min(MmochatConstant.moneyParamForHonorGame
				* me.getHonor(), Integer.MAX_VALUE);
		if (me.getSmall_money() < moneyNeed) {
			CreateTlvWin tlv = getHonorGameTlv(me);
			CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
			msgbox.setContent(new Text("您的金钱不足" + moneyNeed + "文，无法竞猜!"));
			msgbox.setLeftName("确定");
			return MmochatUtil.tlvResponse(req.getHallState(), new CloseWinTLV(
					MmochatConstant.TLV_WIN_HONOR), tlv, msgbox);
		}

		synchronized (me) {
			if (me.getHonor() <= 0) {
				CreateTlvWin tlv = getHonorGameTlv(me);
				CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
				msgbox.setContent(new Text("您的威望不足1点!"));
				msgbox.setLeftName("确定");
				return MmochatUtil.tlvResponse(req.getHallState(),
						new CloseWinTLV(MmochatConstant.TLV_WIN_HONOR), tlv,
						msgbox);
			}
			moneyNeed = (int) Math.min(MmochatConstant.moneyParamForHonorGame
					* me.getHonor(), Integer.MAX_VALUE);
			if (me.getSmall_money() < moneyNeed) {
				CreateTlvWin tlv = getHonorGameTlv(me);
				CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
				msgbox.setContent(new Text("您的金钱不足" + moneyNeed + "文，无法竞猜!"));
				msgbox.setLeftName("确定");
				return MmochatUtil.tlvResponse(req.getHallState(),
						new CloseWinTLV(MmochatConstant.TLV_WIN_HONOR), tlv,
						msgbox);
			}
			String msg = "";
			long oldHonor = me.getHonor();
			if (MmochatUtil.isInPercent(30)) {
				// 翻倍
				me.doubleHonor();
				msg = MmochatUtil.wrapColor("恭喜!恭喜!您的威望翻倍了!", Color.green);
			} else {
				// 减半
				me.halfHonor();
				msg = MmochatUtil.wrapColor("真可惜!您的威望减半了!", Color.red);
			}
			try {
				MmochatDao.saveHonorAndSmallMoney(me, moneyNeed);
			} catch (Exception e) {
				e.printStackTrace();
				me.setHonor(oldHonor);
				return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
			}
			me.addAndUpdateSmall_money(-1 * moneyNeed);

			CreateTlvWin tlv = getHonorGameTlv(me);
			CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
			msgbox.setContent(new Text(msg));
			msgbox.setLeftName("确定");
			return MmochatUtil.tlvResponse(req.getHallState(), new CloseWinTLV(
					MmochatConstant.TLV_WIN_HONOR), tlv, msgbox);
		}
	}

	// 9.41 认主
	@SkymobiService
	public SkymobiProtocolMessage handleC_9_41(SkymobiHandler handler,
			Mmochat_9_41C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		switch (req.getIndex()) {
		case 1: {
			// 装备法宝认主
			int gridNum = 0;
			String intro = "";
			String detail = "";

			gridNum = 1;
			intro += "提交:需要认主的装备或法宝、"
					+ MmochatUtil.getColorMoney(MmochatConstant
							.getModifyEquipPrice()) + "文\n";

			intro += MmochatUtil.wrapColor("说明:<菜单>-<改造说明>", Color.yellow);

			detail = "认主后的装备或法宝，无法进行交易，遗弃，回收，商店出售等操作。可以防止账号被盗等情况下贵重物品的安全。\n"
					+ "认主后的物品可以进行解除认主，解除认主需要"
					+ (MmochatConstant.releaseOwnerInterval / MmochatConstant.MS_PER_DAY)
					+ "天时间，在此期间可以随时中断解除认主，" + "如果需要中断解除认主，只需要再次进行认主即可。\n";

			Mmochat_14_11S pack = new Mmochat_14_11S();
			pack.setType(MmochatNpcItemType.装备法宝认主);
			pack.setTitle("装备法宝认主");
			pack.setIntro(intro);
			pack.setDetail(detail);
			pack.setGridNum(gridNum);
			return pack;
		}
		case 2: {
			// 宠物认主
			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinType(WinType.List);
			tlv.setLeftName("认主");
			tlv.setRightName("返回");
			tlv.setTitle("宠物认主");
			tlv.setWinHeight(228);
			tlv.addRightTLV(new CloseWinTLV());

			for (MmochatPet pet : me.getPets().values()) {
				if (pet.getOwnerState() != MmochatObjOwnerState.已认主) {
					String item = pet.getName() + "\n";
					item += "类型:" + pet.getPetTypeName() + "\n";
					item += "等级:" + pet.getLevel() + "\n";
					item += "武学:" + pet.getDao();
					tlv.addItemEvent(item, new ClearDataTLV(), new AddDataTLV(
							(int) pet.getId()));
				}
			}

			CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
			msgbox
					.setContent(new Text(
							"认主后无法进行交易、遗弃或出售。解除认主需要"
									+ (MmochatConstant.releaseOwnerInterval / MmochatConstant.MS_PER_DAY)
									+ "天时间。" + "您确定要对此宠物进行认主么?"));
			msgbox.setLeftName("确定");
			msgbox.setRightName("取消");
			msgbox.addLeftTLV(new SendDataTLV(MmochatConstant
					.getClientModuleId(), MmochatMain.getModuleInstID(),
					MmochatConstant.MSGCODE_MMOCHAT_C_9_42, (int) req
							.getRoleId()));

			ShowWaitingMsgBoxTLV wait = new ShowWaitingMsgBoxTLV();
			wait.setShowCancel(false);
			msgbox.addLeftTLV(wait);

			tlv.addLeftTLV(msgbox);
			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		case 3: {
			// 装备法宝解除认主
			int gridNum = 0;
			String intro = "";
			String detail = "";

			gridNum = 1;
			intro += "提交:需要解除认主的装备或法宝、"
					+ MmochatUtil.getColorMoney(MmochatConstant
							.getModifyEquipPrice()) + "文\n";

			intro += MmochatUtil.wrapColor("说明:<菜单>-<改造说明>", Color.yellow);

			detail = "解除认主需要"
					+ (MmochatConstant.releaseOwnerInterval / MmochatConstant.MS_PER_DAY)
					+ "天时间，在此期间可以随时中断解除认主，" + "如果需要中断解除认主，只需要再次进行认主即可。\n";

			Mmochat_14_11S pack = new Mmochat_14_11S();
			pack.setType(MmochatNpcItemType.装备法宝解除认主);
			pack.setTitle("装备法宝解除认主");
			pack.setIntro(intro);
			pack.setDetail(detail);
			pack.setGridNum(gridNum);
			return pack;

		}
		case 4: {
			// 宠物解除认主
			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinType(WinType.List);
			tlv.setLeftName("认主");
			tlv.setRightName("返回");
			tlv.setTitle("宠物解除认主");
			tlv.setWinHeight(228);
			tlv.addRightTLV(new CloseWinTLV());

			for (MmochatPet pet : me.getPets().values()) {
				if (pet.getOwnerState() != MmochatObjOwnerState.未认主) {
					String item = pet.getName() + "\n";
					item += "类型:" + pet.getPetTypeName() + "\n";
					item += "等级:" + pet.getLevel() + "\n";
					item += "武学:" + pet.getDao() + "\n";
					item += "状态:" + pet.getOwnerState().toString();
					tlv.addItemEvent(item, new ClearDataTLV(), new AddDataTLV(
							(int) pet.getId()));
				}
			}
			tlv.addLeftTLV(new SendDataTLV(MmochatConstant.getClientModuleId(),
					MmochatMain.getModuleInstID(),
					MmochatConstant.MSGCODE_MMOCHAT_C_9_43, (int) req
							.getRoleId()));
			ShowWaitingMsgBoxTLV wait = new ShowWaitingMsgBoxTLV();
			wait.setShowCancel(false);
			tlv.addLeftTLV(wait);
			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		case 5: {
			// 认主系统说明
			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinType(WinType.Text);
			tlv.setRightName("返回");
			tlv.setTitle("认主系统说明");
			tlv.setWinHeight(188);
			tlv.addRightTLV(new CloseWinTLV());

			String content = MmochatUtil.wrapColor("[物品认主]", Color.yellow);
			content += "\n装备、法宝、宠物进行认主后，以及在解除认主期间，都无法进行交易、遗弃、回收、出售操作。"
					+ "可以防止被盗号时，贵重物品不受损失。\n\n";
			content += MmochatUtil.wrapColor("[解除认主]", Color.yellow);
			content += "\n认主的物品可以进行解除认主操作。申请解除认主后，物品进入<解除认主中>状态，"
					+ (MmochatConstant.releaseOwnerInterval / MmochatConstant.MS_PER_DAY)
					+ "天后正式解除认主。" + "在<解除认主中>状态下，无法进行交易、遗弃、回收、出售操作。在解除期间，"
					+ "可以再次进行认主，以中止解除认主状态。\n\n";
			content += MmochatUtil.wrapColor("[安全提示]", Color.yellow);
			content += "\n每次登陆游戏时，如果您有<解除认主中>的物品，系统都会通过系统频道进行提示。"
					+ "如果这不是您自己执行的解除操作，很有可能您的账号信息已被盗取，请尽快修改账号密码，并重新进行认主操作。";
			tlv.setContent(new Text(content));
			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		default:
			break;
		}
		return MmochatUtil.msgbox(req.getHallState(), "此功能暂未开放!");
	}

	// 9.42 宠物认主
	@SkymobiService
	public SkymobiProtocolMessage handleC_9_42(SkymobiHandler handler,
			Mmochat_9_42C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		MmochatPet pet = me.getPetAlongById(req.getPetId());
		if (pet == null) {
			return MmochatUtil.msgbox(req.getHallState(), "该宠物不存在，请退出重进游戏!");
		}
		if (pet.getOwnerState() == MmochatObjOwnerState.已认主) {
			return MmochatUtil.msgbox(req.getHallState(), "该宠物已认主，无需再认主!");
		}
		if (pet.getBorrowFromRoleId() != null) {
			return MmochatUtil.msgbox(req.getHallState(), "该宠物是借来的，无法认主!");
		}
		MmochatObjOwnerState oldState = pet.getOwnerState();
		pet.setOwnerState(MmochatObjOwnerState.已认主);
		try {
			MmochatDao.updateRolePets(me);
		} catch (Exception e) {
			e.printStackTrace();
			pet.setOwnerState(oldState);
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		Mmochat_5_10S pack = new Mmochat_5_10S();
		pack.addPet(pet);
		MmochatUtil.sendCommonPack(me, pack);
		return MmochatUtil.msgbox(req.getHallState(),
				"认主成功!此宠物在认主期间，无法进行交易、遗弃、出售等操作。");
	}

	// 9.43 宠物解除认主
	@SkymobiService
	public SkymobiProtocolMessage handleC_9_43(SkymobiHandler handler,
			Mmochat_9_43C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		MmochatPet pet = me.getPetAlongById(req.getPetId());
		if (pet == null) {
			return MmochatUtil.msgbox(req.getHallState(), "该宠物不存在，请退出重进游戏!");
		}
		if (pet.getOwnerState() == MmochatObjOwnerState.未认主) {
			return MmochatUtil.msgbox(req.getHallState(), "该宠物未认主，无需解除!");
		}
		if (pet.getBorrowFromRoleId() != null) {
			return MmochatUtil.msgbox(req.getHallState(), "该宠物是借来的，无法解除认主!");
		}
		if (pet.getOwnerState() == MmochatObjOwnerState.解除认主中) {
			long releaseTime = pet.getReleaseOwnerStartTime()
					+ MmochatConstant.releaseOwnerInterval;
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
			String t = sdf.format(new Date(releaseTime));
			return MmochatUtil.msgbox(req.getHallState(), "该宠物已进入解除认主状态，" + t
					+ "时将正式解除，当前无须再次解除。");
		}
		MmochatObjOwnerState oldState = pet.getOwnerState();
		pet.setOwnerState(MmochatObjOwnerState.解除认主中);
		pet.setReleaseOwnerStartTime(System.currentTimeMillis());
		try {
			MmochatDao.updateRolePets(me);
		} catch (Exception e) {
			e.printStackTrace();
			pet.setOwnerState(oldState);
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		Mmochat_5_10S pack = new Mmochat_5_10S();
		pack.addPet(pet);
		MmochatUtil.sendCommonPack(me, pack);

		long releaseTime = pet.getReleaseOwnerStartTime()
				+ MmochatConstant.releaseOwnerInterval;
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
		String t = sdf.format(new Date(releaseTime));
		return MmochatUtil.msgbox(req.getHallState(), "该宠物已进入解除认主状态，" + t
				+ "时将正式解除。在此期间，如果需要中断解除过程，只需再次对宠物进行认主。");
	}

	// 9.44 设置钱庄密码
	@SkymobiService
	public SkymobiProtocolMessage handleC_9_44(SkymobiHandler handler,
			Mmochat_9_44C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		String pwd = req.getPwd();
		if (pwd.length() < 6 || pwd.length() > 18) {
			return MmochatUtil.msgbox(req.getHallState(), "钱庄密码只能由6到18个字组成!");
		}
		for (String sim : simplePwd) {
			if (pwd.equals(sim)) {
				return MmochatUtil
						.msgbox(req.getHallState(), "您的密码过于简单，请重新设置!");
			}
		}

		try {
			MmochatDao.updateStorePwd(pwd, MmochatStorePwdState.已设置钱庄密码
					.getValue(), 0, me.getRoleId());
		} catch (Exception e) {
			e.printStackTrace();
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		me.setStore_pwd_state(MmochatStorePwdState.已设置钱庄密码);
		me.setStore_pwd(pwd);
		me.setHasCheckStorePwd(false);

		String msg = "您的钱庄密码创建成功，请将密码记下来："
				+ MmochatUtil.wrapColor(pwd, Color.magenta)
				+ "，"
				+ "登陆游戏后的首次进行涉及安全的操作时，需要输入一次密码。"
				+ "忘记密码时可进行清除密码操作，此操作需要"
				+ (MmochatConstant.releaseStorePwdInterval / MmochatConstant.MS_PER_DAY)
				+ "天时间生效!";
		MmochatFriendService.sendSystemMsgToPersonByFriendMessage(me, msg);
		return MmochatUtil.msgbox(req.getHallState(), msg);
	}

	// 9.45 修改钱庄密码
	@SkymobiService
	public SkymobiProtocolMessage handleC_9_45(SkymobiHandler handler,
			Mmochat_9_45C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		if (me.getStore_pwd_state() == MmochatStorePwdState.未设置钱庄密码) {
			return MmochatUtil.msgbox(req.getHallState(), "您还没有钱庄密码，请先创建钱庄密码!");
		}
		String pwd = req.getPwd();
		try {
			if (pwd.length() != me.getStore_pwd().length()
					|| !pwd.endsWith(me.getStore_pwd())) {
				return MmochatUtil.msgbox(req.getHallState(), "钱庄密码错误!");
			}
		} catch (Exception e) {
			return MmochatUtil.msgbox(req.getHallState(), "钱庄密码错误!");
		}

		CreateEditBoxTLV edit = new CreateEditBoxTLV();
		edit.setTitle("请输入" + MmochatUtil.wrapColor("新的", Color.yellow)
				+ "钱庄密码!");
		edit.setLeftName("确定");
		edit.setRightName("取消");
		edit.setContentLenMax(18);
		edit.setBoxType(CreateEditBoxTLV.TYPE_MSGBOX);
		edit.setInputType(CreateEditBoxTLV.INPUT_ANY << 4);
		edit.addLeftTLV(new ClearDataTLV());
		edit.addLeftTLV(new AddDataTLV((int) me.getRoleId()));
		edit.addLeftTLV(new AddEditBoxTLV());
		edit.addLeftTLV(new SendDataTLV(MmochatConstant.getClientModuleId(),
				MmochatMain.getModuleInstID(),
				MmochatConstant.MSGCODE_MMOCHAT_C_9_44, null));
		ShowWaitingMsgBoxTLV wait = new ShowWaitingMsgBoxTLV();
		wait.setShowCancel(false);
		edit.addLeftTLV(wait);

		return MmochatUtil.tlvResponse(req.getHallState(), edit);
	}

	private CreateTlvWin getClearStorePwdTlv(MmochatPlayer me) {
		CreateTlvWin tlv = new CreateTlvWin();
		tlv.setWinType(WinType.Text);
		tlv.setRightName("返回");
		tlv.setTitle("清除钱庄密码");
		tlv.setWinHeight(188);
		tlv.setWinId(MmochatConstant.TLV_WIN_CLEARPWD);
		tlv.addRightTLV(new CloseWinTLV(MmochatConstant.TLV_WIN_CLEARPWD));

		String content = "";
		if (me.getStore_pwd_state() == MmochatStorePwdState.已设置钱庄密码) {
			tlv.setLeftName("清除");
			content += "您已设置钱庄密码!\n";
			content += "如果您忘记了钱庄密码，可以使用本功能申请清除，申请清除"
					+ (MmochatConstant.releaseStorePwdInterval / MmochatConstant.MS_PER_DAY)
					+ "天后密码将正式清空。在此期间，您可以在本界面，随时中止此操作。";
			tlv.addLeftTLV(new ClearDataTLV());
			tlv.addLeftTLV(new AddDataTLV((int) me.getRoleId()));
			tlv.addLeftTLV(new SendDataTLV(MmochatConstant.getClientModuleId(),
					MmochatMain.getModuleInstID(),
					MmochatConstant.MSGCODE_MMOCHAT_C_9_46, (int) 1));
		} else if (me.getStore_pwd_state() == MmochatStorePwdState.清除钱庄密码中) {
			tlv.setLeftName("中止");
			long endTime = me.getReleaseStorePwdTime()
					+ MmochatConstant.releaseStorePwdInterval;
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
			String t = sdf.format(new Date(endTime));
			content += "您已经申请清除密码，密码将在" + MmochatUtil.wrapColor(t, Color.red)
					+ "正式解除!清除密码是在登陆游戏时进行执行的，如果解除时间已到仍未解除，"
					+ "您可以退出游戏重进进行解除。\n\n";
			content += MmochatUtil
					.wrapColor("您可以按<中止>按钮，中止清除密码。", Color.yellow);
			tlv.addLeftTLV(new ClearDataTLV());
			tlv.addLeftTLV(new AddDataTLV((int) me.getRoleId()));
			tlv.addLeftTLV(new SendDataTLV(MmochatConstant.getClientModuleId(),
					MmochatMain.getModuleInstID(),
					MmochatConstant.MSGCODE_MMOCHAT_C_9_46, (int) 2));
		} else {
			content += "您尚未设置钱庄密码，无须清除!";
		}

		tlv.setContent(new Text(content));
		return tlv;
	}

	// 9.46 清除钱庄密码
	@SkymobiService
	public SkymobiProtocolMessage handleC_9_46(SkymobiHandler handler,
			Mmochat_9_46C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		switch (req.getIndex()) {
		case 1: {
			// 清除
			if (me.getStore_pwd_state() == MmochatStorePwdState.未设置钱庄密码) {
				return MmochatUtil.msgbox(req.getHallState(), "您未设置密码，无须清除!");
			} else if (me.getStore_pwd_state() == MmochatStorePwdState.清除钱庄密码中) {
				return MmochatUtil.msgbox(req.getHallState(),
						"当前已经在清除密码中了，请刷新再看!");
			}
			long curTime = System.currentTimeMillis();
			try {
				MmochatDao.updateStorePwd(me.getStore_pwd(),
						MmochatStorePwdState.清除钱庄密码中.getValue(), curTime, me
								.getRoleId());
			} catch (Exception e) {
				e.printStackTrace();
				return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
			}
			me.setStore_pwd_state(MmochatStorePwdState.清除钱庄密码中);
			me.setReleaseStorePwdTime(curTime);

			CreateTlvWin tlv = getClearStorePwdTlv(me);
			return MmochatUtil.tlvResponse(req.getHallState(), new CloseWinTLV(
					MmochatConstant.TLV_WIN_CLEARPWD), tlv);
		}
		case 2: {
			// 中止清除
			if (me.getStore_pwd_state() == MmochatStorePwdState.未设置钱庄密码) {
				return MmochatUtil.msgbox(req.getHallState(), "您未设置密码!");
			} else if (me.getStore_pwd_state() != MmochatStorePwdState.清除钱庄密码中) {
				return MmochatUtil.msgbox(req.getHallState(), "当前未在清除钱庄密码!");
			}

			try {
				MmochatDao.updateStorePwd(me.getStore_pwd(),
						MmochatStorePwdState.已设置钱庄密码.getValue(), 0, me
								.getRoleId());
			} catch (Exception e) {
				e.printStackTrace();
				return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
			}
			me.setStore_pwd_state(MmochatStorePwdState.已设置钱庄密码);

			CreateTlvWin tlv = getClearStorePwdTlv(me);
			return MmochatUtil.tlvResponse(req.getHallState(), new CloseWinTLV(
					MmochatConstant.TLV_WIN_CLEARPWD), tlv);
		}
		default:
			break;
		}
		return null;
	}

	// 返回true:则需要执行验证密码；false则不执行验证密码
	public static boolean checkStorePwd(MmochatPlayer me) {
		if (me == null) {
			return false;
		}
		if (me.getStore_pwd_state() != MmochatStorePwdState.未设置钱庄密码
				&& !me.isHasCheckStorePwd()) {
			// 有密码，且未验证过，进行密码验证
			CreateEditBoxTLV edit = new CreateEditBoxTLV();
			edit.setTitle("请输入钱庄密码:");
			edit.setLeftName("确定");
			edit.setRightName("取消");
			edit.setContentLenMax(18);
			edit.setBoxType(CreateEditBoxTLV.TYPE_MSGBOX);
			edit.setInputType(CreateEditBoxTLV.INPUT_ANY << 4);
			edit.addLeftTLV(new ClearDataTLV());
			edit.addLeftTLV(new AddDataTLV((int) me.getRoleId()));
			edit.addLeftTLV(new AddEditBoxTLV());
			edit.addLeftTLV(new SendDataTLV(
					MmochatConstant.getClientModuleId(), MmochatMain
							.getModuleInstID(),
					MmochatConstant.MSGCODE_MMOCHAT_C_9_47, null));
			ShowWaitingMsgBoxTLV wait = new ShowWaitingMsgBoxTLV();
			wait.setShowCancel(true);
			edit.addLeftTLV(wait);

			MmochatUtil.sendCommonPack(me, MmochatUtil
					.tlvResponseWithoutHallState(edit));

			return true;
		}
		return false;
	}

	// 9.47 验证钱庄密码
	@SkymobiService
	public SkymobiProtocolMessage handleC_9_47(SkymobiHandler handler,
			Mmochat_9_47C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		if (me.getStore_pwd_state() == MmochatStorePwdState.未设置钱庄密码) {
			me.setHasCheckStorePwd(true);
			return MmochatUtil.msgbox(req.getHallState(), "您未设置钱庄密码!");
		}

		if (me.getStore_pwd().length() != req.getPwd().length()
				|| !me.getStore_pwd().endsWith(req.getPwd())) {
			return MmochatUtil.msgbox(req.getHallState(), "钱庄密码错误!");
		}
		me.setHasCheckStorePwd(true);
		return MmochatUtil.msgbox(req.getHallState(), "钱庄密码验证成功!请重新再进行上一步操作!");
	}

	// 9.48 结拜
	@SkymobiService
	public SkymobiProtocolMessage handleC_9_48(SkymobiHandler handler,
			Mmochat_9_48C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		if (!me.isInTeam()) {
			return MmochatUtil.msgbox(req.getHallState(),
					"请和您想要结拜的朋友一起组队来我这里!可以2至5人结拜。");
		}
		if (MmochatTeamService.getTeamState(me) != MmochatTeamStateType.队长) {
			return MmochatUtil.msgbox(req.getHallState(),
					"请和您想要结拜的朋友一起组队来我这里!可以2至5人结拜。");
		}
		MmochatTeam team = MmochatTeamService.teams.get(me.getTeamId());
		if (team == null) {
			me.leaveTeam();
			return MmochatUtil.msgbox(req.getHallState(),
					"请和您想要结拜的朋友一起组队来我这里!可以2至5人结拜。");
		}
		if (team.getMemberId().size() < 2) {
			return MmochatUtil.msgbox(req.getHallState(),
					"请和您想要结拜的朋友一起组队来我这里!可以2至5人结拜。");
		}
		if (me.hasChenHaoType(MmochatChenHaoType.结拜称号)) {
			return MmochatUtil.msgbox(req.getHallState(),
					"您已经结拜过了，无法再次结拜!请先解除结拜。");
		}

		List<MmochatPlayer> members = new ArrayList<MmochatPlayer>();
		String nameList = "";
		for (Integer roleId : team.getMemberId().values()) {
			MmochatPlayer member = MmochatMainService.getRoleFromBuffer(roleId);
			if (member == null) {
				return MmochatUtil
						.msgbox(req.getHallState(), "队伍中有成员掉线，请稍后再来!");
			}
			if (member.hasChenHaoType(MmochatChenHaoType.结拜称号)) {
				return MmochatUtil.msgbox(req.getHallState(), member.getName()
						+ "已经结拜过了，无法与你们再次结拜!");
			}
			members.add(member);
			nameList += member.getName() + "、";
		}
		String word = "";
		switch (members.size()) {
		case 2:
			word = "双";
			break;
		case 3:
			word = "三";
			break;
		case 4:
			word = "四";
			break;
		case 5:
			word = "五";
			break;
		default:
			return MmochatUtil.msgbox(req.getHallState(),
					"请和您想要结拜的朋友一起组队来我这里!可以2至5人结拜。");
		}
		String title = req.getTitle();
		if (title.length() != 4) {
			return MmochatUtil.msgbox(req.getHallState(), "结拜称号必须是4个字!");
		}
		if (!MmochatMainService.isRoleNameValid(title)) {
			return MmochatUtil.msgbox(req.getHallState(), "结拜称号中包含非法字符!");
		}
		if (title.indexOf(word, 2) != 2) {
			return MmochatUtil.msgbox(req.getHallState(), members.size()
					+ "人结拜的结拜称号中第3个字必须是"
					+ MmochatUtil.wrapColor(word, Color.yellow));
		}
		if (me.getSmall_money() < MmochatConstant.moneyCostToJieBai) {
			return MmochatUtil.msgbox(req.getHallState(), "结拜需要扣除"
					+ MmochatUtil
							.getColorMoney(MmochatConstant.moneyCostToJieBai)
					+ "文钱,您的金钱不足!");
		}

		me.addAndUpdateSmall_money(-1 * MmochatConstant.moneyCostToJieBai);
		try {
			MmochatDao.updateRoleSmallMoney(me);
		} catch (Exception e) {
			e.printStackTrace();
			me.addAndUpdateSmall_money(MmochatConstant.moneyCostToJieBai);
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙，请稍候再试!");
		}
		MmochatStatisticsService.addSmallMoneyCost(
				MmochatSmallMoneyCostType.结拜, -1
						* MmochatConstant.moneyCostToJieBai);

		MmochatChenHao chenhao = new MmochatChenHao();
		chenhao.setType(MmochatChenHaoType.结拜称号);
		chenhao.setName(title);
		MmochatEquipAttribute attr = new MmochatEquipAttribute();
		attr.setType(MmochatEquipAttributeType.免伤);
		attr.setValue(3);
		chenhao.addAttr(attr);
		chenhao.setExtraEffectInfo("这是" + nameList + "你们" + members.size()
				+ "人的结拜称号!");

		for (MmochatPlayer member : members) {
			MmochatChenHao.addAndUpdateChenHaoAndSaveSql(member.getRoleId(),
					chenhao);
		}
		MmochatChatService.sendSystemMsg(MmochatUtil.wrapColor(nameList,
				Color.green)
				+ "今日在"
				+ MmochatUtil.wrapColor("余杭猎人", Color.yellow)
				+ "的见证下，"
				+ "义结金兰，结拜称号："
				+ MmochatUtil.wrapColor(title, Color.yellow)
				+ "!");
		return MmochatUtil.msgbox(req.getHallState(), "结拜成功!");
	}

	// 取消结拜
	@SkymobiService
	public SkymobiProtocolMessage handleC_9_49(SkymobiHandler handler,
			Mmochat_9_49C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		MmochatChenHao.delAndUpdateChenHaoAndSaveSql(me.getRoleId(),
				MmochatChenHaoType.结拜称号);
		return MmochatUtil.msgbox(req.getHallState(), "取消结拜成功!");
	}

	// 变更任务
	@SkymobiService
	public SkymobiProtocolMessage handleC_9_50(SkymobiHandler handler,
			Mmochat_9_50C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}

		if (me.getSmall_money() < MmochatConstant.moneyNeedToChangeGangTask) {
			return MmochatUtil.msgbox(req.getHallState(), "您的金钱不足"
					+ MmochatConstant.moneyNeedToChangeGangTask + "文!");
		}

		// 放弃帮派任务
		if (!me.hasGang()) {
			return MmochatUtil.msgbox(req.getHallState(), "您尚未加入帮派!");
		}
		MmochatGang myGang = MmochatGangService.getGangById(me.getGangId());
		if (myGang == null) {
			return MmochatUtil.msgbox(req.getHallState(), "您尚未加入帮派!");
		}
		MmochatTask myTask = me.getUnFinishedTaskByType(MmochatTaskType.帮派任务);
		if (myTask != null
				&& (myTask.getTaskState() == MmochatTaskStateType.已接 || myTask
						.getTaskState() == MmochatTaskStateType.待完成)) {
			me.getTasks().remove(myTask.getTaskId());
			// 下发删除任务
			Mmochat_4_12S pack = new Mmochat_4_12S();
			pack.setTaskId(myTask.getTaskId());
			MmochatUtil.sendCommonPack(me, pack);

			Integer nextTaskId = myTask.getNext_taskId();
			while (nextTaskId != null) {
				MmochatTask task = me.getTaskById(nextTaskId);
				if (task == null) {
					break;
				}
				me.getTasks().remove(nextTaskId);
				// 下发删除任务
				Mmochat_4_12S pack1 = new Mmochat_4_12S();
				pack1.setTaskId(nextTaskId);
				MmochatUtil.sendCommonPack(me, pack1);

				nextTaskId = task.getNext_taskId();
			}
			Integer nextAccept_taskId = myTask.getNextAccept_taskId();
			while (nextAccept_taskId != null) {
				MmochatTask task = me.getTaskById(nextAccept_taskId);
				if (task == null) {
					break;
				}
				me.getTasks().remove(nextAccept_taskId);
				// 下发删除任务
				Mmochat_4_12S pack1 = new Mmochat_4_12S();
				pack1.setTaskId(nextAccept_taskId);
				MmochatUtil.sendCommonPack(me, pack1);

				nextAccept_taskId = task.getNextAccept_taskId();
			}

			// 增加新的任务
			myTask = me.getTaskByType(MmochatTaskType.帮派任务);
			while (myTask != null
					&& (myTask.getTaskState() == MmochatTaskStateType.未接 || myTask
							.getTaskState() == MmochatTaskStateType.已完成)) {
				me.getTasks().remove(myTask.getTaskId());
				myTask = me.getTaskByType(MmochatTaskType.帮派任务);
			}

			List<MmochatTask> taskList = new ArrayList<MmochatTask>();
			for (MmochatTask task : MmochatTaskService.tasks.values()) {
				if (task.getTaskType() == MmochatTaskType.帮派任务) {
					if (task.getAccept_npcId() == MmochatConstant.npcId_gangNpc2_inFile) {
						if (task.canAccept(me)) {
							taskList.add(task);
						}
					}
				}
			}
			if (taskList.size() == 0) {
				return MmochatUtil.msgbox(req.getHallState(), "暂时没有适合您的任务!");
			}
			me.addAndUpdateSmall_money(-1
					* MmochatConstant.moneyNeedToChangeGangTask);
			try {
				MmochatDao.updateRoleSmallMoney(me);
			} catch (Exception e1) {
				e1.printStackTrace();
			}

			int index = MmochatUtil.getRandomValue(taskList.size());
			MmochatTask task = taskList.get(index);
			MmochatTask newTask = task.getClone();
			if (task.getAccept_npcId() == MmochatConstant.npcId_gangNpc2_inFile) {
				newTask.setAccept_npcId(req.getNpcId());
			}
			if (task.getFinish_npcId() == MmochatConstant.npcId_gangNpc2_inFile) {
				newTask.setFinish_npcId(req.getNpcId());
			}
			me.addTask(newTask);
			if (newTask.getAccept_talk().size() == 0) {
				// 没有对话则直接接受任务
				newTask.setTaskState(MmochatTaskStateType.已接);
				CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
				msgbox.setLeftName("确定");
				try {
					MmochatDao.updateRoleTasks(me);
				} catch (Exception e) {
					e.printStackTrace();
					msgbox.setContent(new Text("服务器忙,任务接受失败!"));
					return MmochatUtil.tlvResponse(req.getHallState(),
							new CloseWinTLV(MmochatConstant.TLV_WIN_TASKLIST),
							msgbox);
				}
				msgbox.setContent(new Text("任务接受成功!"));
				// 下发增加任务
				Mmochat_4_11S pack1 = new Mmochat_4_11S();
				pack1.setActionType(0);
				pack1.setMe(me);
				pack1.setTask(newTask);
				MmochatUtil.sendCommonPack(me, pack1);

				return MmochatUtil.tlvResponse(req.getHallState(),
						new CloseWinTLV(MmochatConstant.TLV_WIN_TASKLIST),
						msgbox);
			} else {
				CreateMsgBoxTLVWithBmp msgbox = MmochatTaskService
						.getTaskAcceptTalkMsg(me, newTask, req.getRoleId(),
								newTask.getTaskId(), req.getNpcId());
				return MmochatUtil.tlvResponse(req.getHallState(),
						new CloseWinTLV(MmochatConstant.TLV_WIN_TASKLIST),
						msgbox);
			}
		} else {
			return MmochatUtil.msgbox(req.getHallState(), "您身上没有帮派任务!");
		}
	}

	// 查看我的特殊技能
	public static CreateTlvWin getMySpecialSkillTlv(MmochatPlayer me,
			MmochatSpecialSkill skill) {
		if (skill == null) {
			return null;
		}
		MmochatSpecialSkillType skillType = skill.getType();
		CreateTlvWin tlv = new CreateTlvWin();
		tlv.setWinId(MmochatConstant.TLV_WIN_MYSPECIAL_SKILL);
		tlv.setWinType(WinType.Text);
		tlv.setLeftName("升级");
		tlv.setRightName("返回");
		tlv.setTitle(skillType.toString());
		tlv.setWinHeight(188);
		tlv
				.addRightTLV(new CloseWinTLV(
						MmochatConstant.TLV_WIN_MYSPECIAL_SKILL));
		tlv.addLeftTLV(new ClearDataTLV());
		tlv.addLeftTLV(new AddDataTLV((int) skillType.getValue()));
		tlv.addLeftTLV(new SendDataTLV(MmochatConstant.getClientModuleId(),
				MmochatMain.getModuleInstID(),
				MmochatConstant.MSGCODE_MMOCHAT_C_9_52, (int) me.getRoleId()));
		tlv.addLeftTLV(new ShowWaitingMsgBoxTLV());

		String content = "";
		content += MmochatUtil.wrapColor("当前我的技能状态", Color.yellow) + "\n";
		content += MmochatUtil.wrapColor("技能等级:", Color.green)
				+ skill.getLevel() + "\n";
		content += MmochatUtil.wrapColor("技能经验:", Color.green) + skill.getExp()
				+ "\n";
		content += MmochatUtil.wrapColor("熟练度:", Color.green)
				+ skill.getProficiency() + "\n";
		content += MmochatUtil.wrapColor("当前效果:\n", Color.green);
		switch (skillType) {
		case 横扫千军: {
			content += "在秘籍技能时间内，物攻时，有"
					+ MmochatUtil.wrapColor((int) MmochatSpecialSkillType
							.getAttackRateOf横扫千军(skill.getLevel(), skill
									.getProficiency())
							+ "%机率", Color.magenta)
					+ "使横向最近1个目标额外受到"
					+ MmochatUtil
							.wrapColor(
									(int) (100 * MmochatSpecialSkillType
											.getAttackParamOf横扫千军(skill
													.getLevel()) / MmochatConstant.physicalAttackParam)
											+ "%伤害", Color.magenta) + "!\n";
			break;
		}
		case 一击必杀: {
			content += "在秘籍技能时间内，使用2目标法术技能攻击时，主目标将受到"
					+ MmochatUtil.wrapColor(
							(int) (100 + MmochatSpecialSkillType
									.getAttackParamOf一击必杀(skill.getLevel(),
											skill.getProficiency(), 2))
									+ "%伤害", Color.magenta) + "!\n使用";
			;
			if (skill.getLevel() == 1) {
				content += "3目标";
			} else if (skill.getLevel() == 2) {
				content += "3目标、4目标";
			} else if (skill.getLevel() == 3) {
				content += "3目标、4目标、5目标";
			}
			content += "法术技能攻击时，主目标将受到"
					+ MmochatUtil.wrapColor(
							(int) (100 + MmochatSpecialSkillType
									.getAttackParamOf一击必杀(skill.getLevel(),
											skill.getProficiency(), 3))
									+ "%伤害", Color.magenta) + "!\n";
			break;
		}
		case 道法无边: {
			content += "在秘籍技能时间内，使用";
			if (skill.getLevel() == 1) {
				content += "3目标";
			} else if (skill.getLevel() == 2) {
				content += "3目标、4目标";
			} else if (skill.getLevel() == 3) {
				content += "3目标、4目标、5目标";
			}
			content += "障碍技能时，有"
					+ MmochatUtil.wrapColor((int) MmochatSpecialSkillType
							.getLimitRateOf道法无边(skill.getLevel(), skill
									.getProficiency())
							+ "%机率", Color.magenta) + "使障碍目标增加1个!\n";
			break;
		}
		default:
			break;
		}
		content += MmochatUtil.wrapColor("激活状态:", Color.green);
		if (me.hasPropEffect(MmochatPropType.秘籍技能时间书.getEffectKey())) {
			content += "已激活";
		} else {
			content += "未激活!使用道具<秘籍技能时间书>进行激活!";
		}
		tlv.setContent(new Text(content));
		return tlv;

	}

	@SkymobiService
	public SkymobiProtocolMessage handleC_9_51(SkymobiHandler handler,
			Mmochat_9_51C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		MmochatSpecialSkillType skillType = MmochatSpecialSkillType.get(req
				.getSkillTypeValue());
		if (skillType == null) {
			return MmochatUtil.msgbox(req.getHallState(), "暂无此功能!");
		}
		switch (req.getIndex()) {
		case 1: {
			// 1.查看我的技能
			MmochatSpecialSkill skill = me.getSpecialSkill(skillType);
			if (skill == null || skill.getLevel() == 0) {
				return MmochatUtil.msgbox(req.getHallState(), "您尚未学习此技能!使用<"
						+ skillType.toString() + "秘籍>可以获得此技能!");
			} else {
				CreateTlvWin tlv = getMySpecialSkillTlv(me, skill);
				return MmochatUtil.tlvResponse(req.getHallState(), tlv);
			}
		}
		case 2: {
			// 技能介绍
			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinType(WinType.Text);
			tlv.setRightName("返回");
			tlv.setTitle(skillType.toString());
			tlv.setWinHeight(188);
			tlv.addRightTLV(new CloseWinTLV());
			String content = "";
			content += MmochatUtil
					.wrapColor(skillType.toString(), Color.yellow)
					+ "\n";

			switch (skillType) {
			case 横扫千军: {
				content += "1、技能效果\n";
				content += "2、秘籍技能时间\n";
				content += "3、技能等级介绍\n";
				content += "4、熟练度效果\n\n";
				content += MmochatUtil.wrapColor("详细介绍\n", Color.yellow);
				content += MmochatUtil.wrapColor("1、技能效果\n", Color.green);
				content += "学会横扫千军后，在<秘籍技能时间>内，使用物攻时，被攻击目标的横向最近的1个目标"
						+ "有一定机率受到附加伤害。附加目标只进行横向选取。\n\n";

				content += MmochatUtil.wrapColor("2、秘籍技能时间\n", Color.green);
				content += "秘籍技能时间可以通过使用道具<秘籍技能时间书>来增加，此道具可以在副本等活动中获得。"
						+ "只有在秘籍技能时间内，各类秘籍技能才会生效!\n\n";

				content += MmochatUtil.wrapColor("3、技能等级介绍\n", Color.green);
				content += MmochatUtil.wrapColor("1级横扫千军\n", Color.magenta);
				content += "学习途径：使用道具<横扫千军秘籍>可获得1级技能!\n";
				content += "等级要求：人物达到"
						+ MmochatSpecialSkillType
								.getLevelNeedToLearnOfSpecialSkill(
										MmochatSpecialSkillType.横扫千军, 1)
						+ "级\n";
				content += "技能效果：一定机率对主目标横向最近的1个目标造成"
						+ (int) (100 * MmochatSpecialSkillType
								.getAttackParamOf横扫千军(1) / MmochatConstant.physicalAttackParam)
						+ "%伤害\n";
				content += "升级经验："
						+ MmochatSpecialSkillType.getUpLevelExpOfSpecialSkill(
								MmochatSpecialSkillType.横扫千军, 1) + "\n";

				content += MmochatUtil.wrapColor("2级横扫千军\n", Color.magenta);
				content += "学习途径：1级横扫千军满经验后升级!\n";
				content += "等级要求：人物达到"
						+ MmochatSpecialSkillType
								.getLevelNeedToLearnOfSpecialSkill(
										MmochatSpecialSkillType.横扫千军, 2)
						+ "级\n";
				content += "技能效果：一定机率对主目标横向最近的1个目标造成"
						+ (int) (100 * MmochatSpecialSkillType
								.getAttackParamOf横扫千军(2) / MmochatConstant.physicalAttackParam)
						+ "%伤害\n";
				content += "升级经验："
						+ MmochatSpecialSkillType.getUpLevelExpOfSpecialSkill(
								MmochatSpecialSkillType.横扫千军, 2) + "\n";

				content += MmochatUtil.wrapColor("3级横扫千军\n", Color.magenta);
				content += "学习途径：2级横扫千军满经验后升级!\n";
				content += "等级要求：人物达到"
						+ MmochatSpecialSkillType
								.getLevelNeedToLearnOfSpecialSkill(
										MmochatSpecialSkillType.横扫千军, 3)
						+ "级\n";
				content += "技能效果：一定机率对主目标横向最近的1个目标造成"
						+ (int) (100 * MmochatSpecialSkillType
								.getAttackParamOf横扫千军(3) / MmochatConstant.physicalAttackParam)
						+ "%伤害\n\n";

				content += MmochatUtil.wrapColor("4、熟练度效果\n", Color.green);
				content += "熟练度0-20000对应技能机率10-20%\n\n";
				content += "熟练度20000-60000对应技能机率20-30%\n\n";
				content += "熟练度60000-140000对应技能机率30-40%\n\n";
				content += "熟练度140000-300000对应技能机率40-50%\n\n";
				content += "熟练度300000-620000对应技能机率50-60%\n\n";
				content += "熟练度620000-1260000对应技能机率60-70%\n\n";
				content += "1级技能机率上限为50%,2级技能机率上限为60%,3级技能机率上限为70%";
				break;
			}
			case 一击必杀: {
				content += "1、技能效果\n";
				content += "2、秘籍技能时间\n";
				content += "3、技能等级介绍\n";
				content += "4、熟练度效果\n\n";
				content += MmochatUtil.wrapColor("详细介绍\n", Color.yellow);
				content += MmochatUtil.wrapColor("1、技能效果\n", Color.green);
				content += "学会一击必杀后，在<秘籍技能时间>内，使用多目标法术时，主目标受到伤害增加。\n\n";

				content += MmochatUtil.wrapColor("2、秘籍技能时间\n", Color.green);
				content += "秘籍技能时间可以通过使用道具<秘籍技能时间书>来增加，此道具可以在副本等活动中获得。"
						+ "只有在秘籍技能时间内，各类秘籍技能才会生效!\n\n";

				content += MmochatUtil.wrapColor("3、技能等级介绍\n", Color.green);
				content += MmochatUtil.wrapColor("1级一击必杀\n", Color.magenta);
				content += "学习途径：使用道具<一击必杀秘籍>可获得1级技能!\n";
				content += "等级要求：人物达到"
						+ MmochatSpecialSkillType
								.getLevelNeedToLearnOfSpecialSkill(
										MmochatSpecialSkillType.一击必杀, 1)
						+ "级\n";
				content += "技能效果：使用2目标、3目标法术时，可令主目标受到的伤害增加!\n";
				content += "升级经验："
						+ MmochatSpecialSkillType.getUpLevelExpOfSpecialSkill(
								MmochatSpecialSkillType.一击必杀, 1) + "\n";

				content += MmochatUtil.wrapColor("2级一击必杀\n", Color.magenta);
				content += "学习途径：1级一击必杀满经验后升级!\n";
				content += "等级要求：人物达到"
						+ MmochatSpecialSkillType
								.getLevelNeedToLearnOfSpecialSkill(
										MmochatSpecialSkillType.一击必杀, 2)
						+ "级\n";
				content += "技能效果：使用2目标、3目标、4目标法术时，可令主目标受到的伤害增加!\n";
				content += "升级经验："
						+ MmochatSpecialSkillType.getUpLevelExpOfSpecialSkill(
								MmochatSpecialSkillType.一击必杀, 2) + "\n";

				content += MmochatUtil.wrapColor("3级一击必杀\n", Color.magenta);
				content += "学习途径：2级一击必杀满经验后升级!\n";
				content += "等级要求：人物达到"
						+ MmochatSpecialSkillType
								.getLevelNeedToLearnOfSpecialSkill(
										MmochatSpecialSkillType.一击必杀, 3)
						+ "级\n";
				content += "技能效果：使用2目标、3目标、4目标、5目标法术时，可令主目标受到的伤害增加!\n\n";

				content += MmochatUtil.wrapColor("4、熟练度效果\n", Color.green);
				content += "熟练度0-20000主目标受到120%-125%伤害\n\n";
				content += "熟练度20000-60000主目标受到125%-130%伤害\n\n";
				content += "熟练度60000-140000主目标受到130%-135%伤害\n\n";
				content += "熟练度140000-300000主目标受到135%-140%伤害\n\n";
				content += "熟练度300000-620000主目标受到140%-145%伤害\n\n";
				content += "熟练度620000-1260000主目标受到145%-150%伤害\n\n";
				content += "1级技能伤害上限为140%,2级技能伤害上限为145%,3级技能伤害上限为150%";
				break;
			}
			case 道法无边: {
				content += "1、技能效果\n";
				content += "2、秘籍技能时间\n";
				content += "3、技能等级介绍\n";
				content += "4、熟练度效果\n\n";
				content += MmochatUtil.wrapColor("详细介绍\n", Color.yellow);
				content += MmochatUtil.wrapColor("1、技能效果\n", Color.green);
				content += "学会道法无边后，在<秘籍技能时间>内，使用多目标障碍技能时，有一定机率增加1个障碍目标。\n\n";

				content += MmochatUtil.wrapColor("2、秘籍技能时间\n", Color.green);
				content += "秘籍技能时间可以通过使用道具<秘籍技能时间书>来增加，此道具可以在副本等活动中获得。"
						+ "只有在秘籍技能时间内，各类秘籍技能才会生效!\n\n";

				content += MmochatUtil.wrapColor("3、技能等级介绍\n", Color.green);
				content += MmochatUtil.wrapColor("1级道法无边\n", Color.magenta);
				content += "学习途径：使用道具<道法无边秘籍>可获得1级技能!\n";
				content += "等级要求：人物达到"
						+ MmochatSpecialSkillType
								.getLevelNeedToLearnOfSpecialSkill(
										MmochatSpecialSkillType.道法无边, 1)
						+ "级\n";
				content += "技能效果：使用3目标障碍技能时，一定机率增加1个障碍目标!\n";
				content += "升级经验："
						+ MmochatSpecialSkillType.getUpLevelExpOfSpecialSkill(
								MmochatSpecialSkillType.道法无边, 1) + "\n";

				content += MmochatUtil.wrapColor("2级道法无边\n", Color.magenta);
				content += "学习途径：1级道法无边满经验后升级!\n";
				content += "等级要求：人物达到"
						+ MmochatSpecialSkillType
								.getLevelNeedToLearnOfSpecialSkill(
										MmochatSpecialSkillType.道法无边, 2)
						+ "级\n";
				content += "技能效果：使用3目标、4目标障碍技能时，一定机率增加1个障碍目标!\n";
				content += "升级经验："
						+ MmochatSpecialSkillType.getUpLevelExpOfSpecialSkill(
								MmochatSpecialSkillType.道法无边, 2) + "\n";

				content += MmochatUtil.wrapColor("3级道法无边\n", Color.magenta);
				content += "学习途径：2级道法无边满经验后升级!\n";
				content += "等级要求：人物达到"
						+ MmochatSpecialSkillType
								.getLevelNeedToLearnOfSpecialSkill(
										MmochatSpecialSkillType.道法无边, 3)
						+ "级\n";
				content += "技能效果：使用3目标、4目标、5目标障碍技能时，一定机率增加1个障碍目标!\n\n";

				content += MmochatUtil.wrapColor("4、熟练度效果\n", Color.green);
				content += "熟练度0-20000对应技能机率0%-10%\n\n";
				content += "熟练度20000-60000对应技能机率10%-20%\n\n";
				content += "熟练度60000-140000对应技能机率20%-30%\n\n";
				content += "熟练度140000-300000对应技能机率30%-40%\n\n";
				content += "熟练度300000-620000对应技能机率40%-50%\n\n";
				content += "熟练度620000-1260000对应技能机率50%-60%\n\n";
				content += "1级技能触发机率上限为40%,2级技能触发机率上限为50%,3级技能触发机率的上限为60%";
				break;
			}
			default:
				break;
			}
			tlv.setContent(new Text(content));
			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		case 3: {
			// 3.熟练度训练
			MmochatSpecialSkill skill = me.getSpecialSkill(skillType);
			if (skill == null) {
				return MmochatUtil.msgbox(req.getHallState(), "您尚未学此技能!");
			}
			CreateTlvWin tlv = getTrainningSkillTlv(me, skill);
			return MmochatUtil.tlvResponse(req.getHallState(), tlv);
		}
		default:
			return MmochatUtil.msgbox(req.getHallState(), "暂无此功能!");
		}
	}

	// 升级技能
	@SkymobiService
	public SkymobiProtocolMessage handleC_9_52(SkymobiHandler handler,
			Mmochat_9_52C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		MmochatSpecialSkillType skillType = MmochatSpecialSkillType.get(req
				.getSkillTypeValue());
		if (skillType == null) {
			return MmochatUtil.msgbox(req.getHallState(), "您尚未学此技能!");
		}
		MmochatSpecialSkill skill = me.getSpecialSkill(skillType);
		if (skill == null) {
			return MmochatUtil.msgbox(req.getHallState(), "您尚未学此技能!");
		}
		// 等级、技能经验判断
		int oldLevel = skill.getLevel();
		int nextLevel = skill.getLevel() + 1;
		if (nextLevel > 3) {
			return MmochatUtil.msgbox(req.getHallState(), "此技能已学满，无法继续升级!");
		}
		int levelNeed = MmochatSpecialSkillType
				.getLevelNeedToLearnOfSpecialSkill(skillType, nextLevel);
		if (me.getLevel() < levelNeed) {
			return MmochatUtil.msgbox(req.getHallState(), "升级此技能需要人物达到"
					+ levelNeed + "级，您的等级不够!");
		}
		int expNeed = MmochatSpecialSkillType.getUpLevelExpOfSpecialSkill(
				skillType, skill.getLevel());
		if (skill.getExp() < expNeed) {
			return MmochatUtil.msgbox(req.getHallState(), "升级此技能需要技能经验达到"
					+ expNeed + "点，您当前的技能经验为" + skill.getExp() + "，未达到经验要求!");
		}
		// 升级技能
		skill.setLevel(nextLevel);
		skill.addExp(-1 * expNeed);
		try {
			MmochatDao.updateRoleSpecialSkill(me);
		} catch (Exception e) {
			skill.setLevel(oldLevel);
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}

		String msg = MmochatUtil.wrapColor("恭喜!您的" + skillType.toString()
				+ "升到" + skill.getLevel() + "级了!", Color.yellow);
		CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
		msgbox.setContent(new Text(msg));
		msgbox.setLeftName("确定");

		CreateTlvWin tlv = getMySpecialSkillTlv(me, skill);
		return MmochatUtil.tlvResponse(req.getHallState(), new CloseWinTLV(
				MmochatConstant.TLV_WIN_MYSPECIAL_SKILL), tlv, msgbox);
	}

	@SuppressWarnings("deprecation")
	public static CreateTlvWin getTrainningSkillTlv(MmochatPlayer me,
			MmochatSpecialSkill skill) {
		MmochatSpecialSkillType skillType = skill.getType();

		MmochatDailyActivityType type;
		switch (skillType) {
		case 横扫千军:
			type = MmochatDailyActivityType.横扫千军训练;
			break;
		case 一击必杀:
			type = MmochatDailyActivityType.一击必杀训练;
			break;
		case 道法无边:
			type = MmochatDailyActivityType.道法无边训练;
			break;
		default:
			return null;
		}

		CreateTlvWin tlv = new CreateTlvWin();
		tlv.setWinType(WinType.Text);
		tlv.setLeftName("训练");
		tlv.setRightName("返回");
		tlv.setTitle(skillType.toString());
		tlv.setWinHeight(188);
		tlv.setWinId(MmochatConstant.TLV_WIN_TRAIN_SPECIAL_SKILL);
		tlv.addRightTLV(new CloseWinTLV(
				MmochatConstant.TLV_WIN_TRAIN_SPECIAL_SKILL));

		tlv.addLeftTLV(new ClearDataTLV());
		tlv.addLeftTLV(new AddDataTLV((int) skillType.getValue()));
		tlv.addLeftTLV(new SendDataTLV(MmochatConstant.getClientModuleId(),
				MmochatMain.getModuleInstID(),
				MmochatConstant.MSGCODE_MMOCHAT_C_9_53, (int) me.getRoleId()));
		ShowWaitingMsgBoxTLV wait = new ShowWaitingMsgBoxTLV();
		wait.setShowCancel(false);
		tlv.addLeftTLV(wait);

		String content = "";
		content += MmochatUtil.wrapColor(skillType.toString() + "\n",
				Color.yellow);
		content += MmochatUtil.wrapColor("熟练度：", Color.green);
		content += skill.getProficiency() + "\n";
		content += MmochatUtil.wrapColor("训练次数：", Color.green);
		MmochatDailyActivity activity = me.getDailyActivities().get(type);
		if (activity == null) {
			// 第一次训练
			activity = new MmochatDailyActivity();
			activity.setType(type);
			me.getDailyActivities().put(type, activity);
		} else {
			Date now = new Date();
			Date lastDate = new Date(activity.getLastTime());
			if (now.getDate() == lastDate.getDate()
					&& now.getMonth() == lastDate.getMonth()
					&& now.getYear() == lastDate.getYear()) {
				// 今天参加过此活动
			} else {
				// 今天没有参加过此活动
				activity.setDailyTimes(0);
			}
		}
		int activityTimes = activity.getDailyTimes(); // 已经训练的次数
		content += activityTimes + "/" + activity.getType().getMaxDailyTimes()
				+ "\n";
		content += MmochatUtil.wrapColor("训练消耗：", Color.green);
		content += bigMoneyForTrain[activityTimes] + "元宝\n\n";
		content += MmochatUtil.wrapColor("训练说明：", Color.green);
		content += "每次训练可以随机增加1000-3000点熟练度，有一定机率获得10000点熟练度。"
				+ "每天可以进行一次免费训练和五次收费训练。费用第一次最低，第五次最高。";
		tlv.setContent(new Text(content));
		return tlv;
	}

	// 训练熟练度
	@SuppressWarnings("deprecation")
	@SkymobiService
	public SkymobiProtocolMessage handleC_9_53(SkymobiHandler handler,
			Mmochat_9_53C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		MmochatSpecialSkillType skillType = MmochatSpecialSkillType.get(req
				.getSkillTypeValue());
		if (skillType == null) {
			return MmochatUtil.msgbox(req.getHallState(), "您尚未学此技能!");
		}
		MmochatSpecialSkill skill = me.getSpecialSkill(skillType);
		if (skill == null) {
			return MmochatUtil.msgbox(req.getHallState(), "您尚未学此技能!");
		}
		MmochatDailyActivityType type;
		switch (skillType) {
		case 横扫千军:
			type = MmochatDailyActivityType.横扫千军训练;
			break;
		case 一击必杀:
			type = MmochatDailyActivityType.一击必杀训练;
			break;
		case 道法无边:
			type = MmochatDailyActivityType.道法无边训练;
			break;
		default:
			return MmochatUtil.msgbox(req.getHallState(), "您尚未学此技能!");
		}

		MmochatDailyActivity activity = me.getDailyActivities().get(type);
		if (activity == null) {
			// 第一次训练
			activity = new MmochatDailyActivity();
			activity.setType(type);
			me.getDailyActivities().put(type, activity);
		} else {
			Date now = new Date();
			Date lastDate = new Date(activity.getLastTime());
			if (now.getDate() == lastDate.getDate()
					&& now.getMonth() == lastDate.getMonth()
					&& now.getYear() == lastDate.getYear()) {
				// 今天参加过此活动
			} else {
				// 今天没有参加过此活动
				activity.setDailyTimes(0);
			}
		}
		int activityTimes = activity.getDailyTimes(); // 已经训练的次数
		if (activityTimes >= activity.getType().getMaxDailyTimes()) {
			return MmochatUtil.msgbox(req.getHallState(), "每天最多进行"
					+ activity.getType().getMaxDailyTimes() + "次"
					+ skillType.toString() + "训练，请明天再来!");
		}

		int bigmoneyNeed = bigMoneyForTrain[activityTimes];
		if (bigmoneyNeed < 0) {
			bigmoneyNeed = 0;
		}
		if (me.getBig_money() < bigmoneyNeed) {
			return MmochatUtil.msgbox(req.getHallState(), "本次训练需要消耗"
					+ bigmoneyNeed + "元宝，您的元宝不足!");
		}
		// 扣除元宝、增加熟练度、增加训练次数、保存数据库
		boolean bigAward = false;
		long proficiency = 0;
		if (MmochatUtil.isInPercent(1)) {
			bigAward = true;
			proficiency = 10000;
		} else {
			proficiency = MmochatUtil.getRandomValue(1000, 3000);
		}
		// 增加熟练度
		skill.addProficiency(proficiency);
		// 增加训练次数
		activity.addDailyTimes(1);
		activity.setLastTime(System.currentTimeMillis());
		// 扣除元宝
		me.addBig_money(-1 * bigmoneyNeed);

		// 数据库
		try {
			MmochatDao.trainRoleSpecialSkill(me);
		} catch (Exception e) {
			e.printStackTrace();
		}
		MmochatStatisticsService.addBigMoneyCost(MmochatBigMoneyCostType.熟练度训练,
				-1 * bigmoneyNeed);
		if (bigAward) {
			String info = MmochatUtil.wrapColor(me.getName(), Color.green)
					+ "在江宁<海慧法师>处" + "训练" + skillType.toString()
					+ "熟练度时，顿悟天机，获得"
					+ MmochatUtil.wrapColor("10000点熟练度", Color.magenta) + "!";
			info = MmochatUtil.wrapColor(info, Color.yellow);
			MmochatChatService.sendSystemMsg(info);
		}

		CreateMsgBoxTLV msgbox = new CreateMsgBoxTLV();
		msgbox.setContent(new Text("恭喜，训练完成!您的" + skillType.toString()
				+ "技能的熟练度增加" + MmochatUtil.wrapColor(proficiency, Color.yellow)
				+ "!您花费了" + bigmoneyNeed + "元宝!"));
		msgbox.setLeftName("确定");
		CreateTlvWin tlv = getTrainningSkillTlv(me, skill);
		return MmochatUtil.tlvResponse(req.getHallState(), new CloseWinTLV(
				MmochatConstant.TLV_WIN_TRAIN_SPECIAL_SKILL), tlv, msgbox);
	}

	// 竞技点兑换称号
	@SkymobiService
	public SkymobiProtocolMessage handleC_9_54(SkymobiHandler handler,
			Mmochat_9_54C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		MmochatChenHaoType chenHaoType = MmochatChenHaoType.get(req
				.getChenHaoType());
		if (chenHaoType == null) {
			return MmochatUtil.msgbox(req.getHallState(), "没有此称号出售!");
		}
		int price = 100000000;
		MmochatChenHao chenHao = new MmochatChenHao();
		chenHao.setType(chenHaoType);
		chenHao.setLifeTime(MmochatConstant.MS_PER_DAY * 7);
		SimpleDateFormat sdf = new SimpleDateFormat("MM月dd号");
		String curTimeString = sdf.format(new Date());
		chenHao.setExtraEffectInfo(curTimeString + "开始，限时7天!");

		String msg = null;
		switch (chenHaoType) {
		case 擂台新贵: {
			price = 1000;
			MmochatEquipAttribute attr = new MmochatEquipAttribute();
			attr.setType(MmochatEquipAttributeType.全属性);
			attr.setValue(1);
			chenHao.addAttr(attr);
			break;
		}
		case 擂台高手: {
			price = 3000;
			MmochatEquipAttribute attr = new MmochatEquipAttribute();
			attr.setType(MmochatEquipAttributeType.全属性);
			attr.setValue(3);
			chenHao.addAttr(attr);
			break;
		}
		case 擂台狂人: {
			price = 6000;
			MmochatEquipAttribute attr = new MmochatEquipAttribute();
			attr.setType(MmochatEquipAttributeType.全属性);
			attr.setValue(6);
			chenHao.addAttr(attr);
			break;
		}
		case 擂台小神: {
			price = 10000;
			MmochatEquipAttribute attr = new MmochatEquipAttribute();
			attr.setType(MmochatEquipAttributeType.全天赋);
			attr.setValue(1);
			chenHao.addAttr(attr);

			attr = new MmochatEquipAttribute();
			attr.setType(MmochatEquipAttributeType.全属性);
			attr.setValue(6);
			chenHao.addAttr(attr);

			msg = "全区服通告:";
			if (me.getCurChenHaoInfo() != null) {
				msg += MmochatUtil.wrapColor(me.getCurChenHaoInfo(),
						Color.yellow)
						+ "区的";
			}
			msg += MmochatUtil.wrapColor(me.getName(), Color.green)
					+ "在跨服擂台战功显赫，获得了"
					+ MmochatUtil.wrapColor("擂台小神", Color.red) + "的称号!";
			break;
		}
		case 擂台武神: {
			price = 15000;
			MmochatEquipAttribute attr = new MmochatEquipAttribute();
			attr.setType(MmochatEquipAttributeType.全天赋);
			attr.setValue(1);
			chenHao.addAttr(attr);

			attr = new MmochatEquipAttribute();
			attr.setType(MmochatEquipAttributeType.全属性);
			attr.setValue(10);
			chenHao.addAttr(attr);

			msg = "全区服通告:";
			if (me.getCurChenHaoInfo() != null) {
				msg += MmochatUtil.wrapColor(me.getCurChenHaoInfo(),
						Color.yellow)
						+ "区的";
			}
			msg += MmochatUtil.wrapColor(me.getName(), Color.green)
					+ "在跨服擂台所向披靡，获得了"
					+ MmochatUtil.wrapColor("擂台武神", Color.red) + "的称号!";
			break;
		}
		case 擂台战神: {
			price = 30000;
			MmochatEquipAttribute attr = new MmochatEquipAttribute();
			attr.setType(MmochatEquipAttributeType.全天赋);
			attr.setValue(2);
			chenHao.addAttr(attr);

			attr = new MmochatEquipAttribute();
			attr.setType(MmochatEquipAttributeType.全属性);
			attr.setValue(15);
			chenHao.addAttr(attr);

			msg = "全区服通告:";
			if (me.getCurChenHaoInfo() != null) {
				msg += MmochatUtil.wrapColor(me.getCurChenHaoInfo(),
						Color.yellow)
						+ "区的";
			}
			msg += MmochatUtil.wrapColor(me.getName(), Color.green)
					+ "在跨服擂台无人能敌，获得了"
					+ MmochatUtil.wrapColor("擂台战神", Color.red) + "的称号!";
			break;
		}
		default:
			break;
		}

		if (me.getPk_score() - MmochatConstant.pkScoreNeedToEnter < price) {
			return MmochatUtil.msgbox(req.getHallState(), "竞技点不足!兑换<"
					+ chenHaoType.toString()
					+ ">需要"
					+ price
					+ "点竞技点。您当前可兑换竞技点为"
					+ Math.max(0, me.getPk_score()
							- MmochatConstant.pkScoreNeedToEnter) + "点(当前竞技点-"
					+ MmochatConstant.pkScoreNeedToEnter + ")");
		}

		Map<MmochatChenHaoType, MmochatChenHao> chenHaoMap = MmochatMain.serverListDaoService
				.getChenHao(me.getRoleId() % 10000000, me.getRegServerInstId());
		if (chenHaoMap != null) {
			chenHaoMap.put(chenHao.getType(), chenHao);
		}
		int oldScore = me.getPk_score();
		me.addPk_score(-1 * price);
		// 保存竞技点和称号
		try {
			String chenHaoStr;
			Gson gson = new Gson();
			chenHaoStr = gson.toJson(chenHaoMap,
					new TypeToken<Map<MmochatChenHaoType, MmochatChenHao>>() {
					}.getType());
			MmochatMain.serverListDaoService.updatePkScoreAndChenHao(me
					.getRoleId() % 10000000, me.getRegServerInstId(), me
					.getPk_score(), chenHaoStr);
		} catch (Exception e) {
			e.printStackTrace();
			me.setPk_score(oldScore);
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		if (msg != null) {
			MmochatChatService.sendSystemMsgToAllServer(msg);
		}
		return MmochatUtil.msgbox(req.getHallState(), "兑换成功!您消耗了" + price
				+ "点竞技点，兑换了7天的<" + chenHaoType.toString() + ">称号，当前您的竞技点还有"
				+ me.getPk_score() + "点。称号只能在您原区服内使用!");
	}

	// 9.61 物伤、法伤、速度子榜
	@SkymobiService
	public SkymobiProtocolMessage handleC_9_61(SkymobiHandler handler,
			Mmochat_9_61C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		MmochatNpcItemType type = MmochatNpcItemType.get(req.getTypeValue());
		int level = req.getLevelRank();
		Map<Integer, MmochatRoleRankInfo> rank = null;

		String headInfo = "";
		switch (type) {
		case 物伤榜:
			rank = physicalRank.get(level);
			headInfo = "物伤:";
			break;
		case 法伤榜:
			rank = magicRank.get(level);
			headInfo = "法伤:";
			break;
		case 速度榜:
			rank = speedRank.get(level);
			headInfo = "速度:";
			break;
		default:
			break;
		}
		if (rank == null) {
			return MmochatUtil.msgbox(req.getHallState(), "暂无此榜数据!");
		}

		String title = level + "-" + (level + 9) + "级榜";

		if (rank.size() == 0) {
			return MmochatUtil.msgbox(req.getHallState(), "暂时还没有此榜!");
		}
		List<MmochatRoleRankInfo> list = new ArrayList<MmochatRoleRankInfo>(
				rank.values());
		Collections.sort(list);

		CreateTlvWin tlv = new CreateTlvWin();
		tlv.setWinType(WinType.List);
		tlv.setRightName("返回");
		tlv.setTitle(title);
		tlv.setWinHeight(188);
		tlv.addRightTLV(new CloseWinTLV());
		int index = 1;
		for (MmochatRoleRankInfo player : list) {
			String item = index + ".";
			if (player.getRoleId() == me.getRoleId()) {
				item += MmochatUtil.wrapColor(player.getName(), Color.magenta);
			} else {
				item += MmochatUtil.wrapColor(player.getName(), Color.yellow);
			}
			item += "\n" + headInfo + player.getValue();
			tlv.addItemEvent(player.getBmpId(), item);
			index++;
		}
		return MmochatUtil.tlvResponse(req.getHallState(), tlv);
	}

	// 9.62 寻怪符飞行
	@SuppressWarnings("deprecation")
	@SkymobiService
	public SkymobiProtocolMessage handleC_9_62(SkymobiHandler handler,
			Mmochat_9_62C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		int mapId = req.getMapId();
		int x = req.getX();
		int y = req.getY();

		// 扣除道具1次
		MmochatPackageGrid grid = me.getPropGridFromPackage(MmochatPropType.飞羽);
		if (grid == null) {
			return MmochatUtil.msgbox(req.getHallState(), "您没有飞羽，请先按9键到商城购买!");
		}

		Date now = new Date();
		if (now.getDay() != 0 && now.getDay() != 6) {
			return MmochatUtil.msgbox(req.getHallState(), "此道具仅限周六、周日使用。");
		}

		MmochatMap newMap;
		List<MmochatPlayer> members;
		MmochatCommonObject prop;
		synchronized (me) {
			grid = me.getPropGridFromPackage(MmochatPropType.飞羽);
			if (grid == null) {
				return MmochatUtil.msgbox(req.getHallState(),
						"您没有飞羽，请先按9键到商城购买!");
			}
			prop = grid.getObject();
			if (prop == null || prop.getPropType() != MmochatPropType.飞羽
					|| prop.isUsedOut()) {
				return MmochatUtil.msgbox(req.getHallState(),
						"您没有飞羽，请先按9键到商城购买!");
			}
			// 将全队传送到指定坐标
			if (me.isInBattle()) {
				log.debug("玩家" + me.getName() + "(skyid=" + me.getSkyId()
						+ ")已进入战斗,无法传送");
				return null;
			}
			newMap = MmochatMapService.getMapByMapId(mapId);
			if (newMap == null) {
				return MmochatUtil
						.msgbox(req.getHallState(), "目标地图已关闭，暂时无法前往!");
			}
			members = new ArrayList<MmochatPlayer>();
			if (me.isInTeam()) {
				MmochatTeam team = MmochatTeamService.teams.get(me.getTeamId());
				if (team == null) {
					me.leaveTeam();
					members.add(me);
				} else {
					if (!team.isTeamLeader(me.getRoleId())) {
						log.debug("玩家" + me.getName() + "(skyid="
								+ me.getSkyId() + ")在队伍中，且不为队长，无法传送;");
						return MmochatUtil.msgbox(req.getHallState(),
								"您在队伍中，请和队长一起行动!");
					}
					for (Integer roleId : team.getMemberId().values()) {
						MmochatPlayer member = MmochatMainService.players
								.get(roleId);
						if (member != null) {
							members.add(member);
						}
					}
				}
			} else {
				members.add(me);
			}
			if (members.size() <= 0) {
				log.debug("玩家" + me.getName() + "(skyid=" + me.getSkyId()
						+ ")传送人数为0，无法传送;");
				return null;
			}
			// 消耗寻怪符
			prop.use(1);
			if (prop.isUsedOut()) {
				grid.setObject(null);
				MmochatStatisticsService.addPropCost(MmochatPropType.飞羽, 1);
			}
		}

		if (!MmochatPropService.needToSavePropSqlPlayerQueue.contains(me)
				&& !MmochatGmService.isSystemExit()) {
			MmochatPropService.needToSavePropSqlPlayerQueue.add(me);
		}

		Mmochat_5_1S pack = new Mmochat_5_1S();
		pack.addGrid(grid);
		MmochatUtil.sendCommonPack(me, pack);

		// 通过x,y决定传送到哪个地图哪个传送口附近
		MmochatMap curMap = MmochatMapService.getMapByMapId(me.getMapId());

		// 将本队人马传到新地图新坐标
		MmochatMapService.tranToNewMap(curMap, me.getLine(), newMap, me
				.getLine(), x, y, members);
		log.debug("玩家" + me.getName() + "(skyid=" + me.getSkyId() + ")完成传送");

		return null;
	}

	// 9.63 武魂介绍
	@SkymobiService
	public SkymobiProtocolMessage handleC_9_63(SkymobiHandler handler,
			Mmochat_9_63C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		CreateTlvWin tlv = new CreateTlvWin();
		tlv.setWinType(WinType.Text);
		tlv.setRightName("返回");
		tlv.setWinHeight(188);
		tlv.addRightTLV(new CloseWinTLV());
		String title = "";
		String content = "";
		switch (req.getIndex()) {
		case 1: {
			title = "什么是武魂";
			content = "武魂是战神之魂，击杀战神后有机率掉落。"
					+ "它是一种容器型法宝，可以装备到身上。武魂本身没有属性，相当于一个空的容器。"
					+ "但武魂可以镶嵌若干个武魂石，武魂石上的技能便会吸附到武魂上，使武魂拥有强大的技能效果。"
					+ "武魂石的部分技能，属于武魂专属技能，在其它地方是不会看到的。";
			break;
		}
		case 3: {
			title = "武魂品质";
			content = "目前已知的武魂品质由低到高为1星至5星。星级越高，掉落机率越小，但可镶嵌武魂石数量越大。"
					+ "1星可镶嵌1个武魂石，5星可镶嵌5个武魂石。由于武魂镶嵌后，可以方便得再将武魂石分离出来，"
					+ "所以在没有得到高星武魂前，可以将武魂石放入低星武魂，等获得高星武魂后，" + "可以再将武魂石转到高星武魂上。";
			break;
		}
		case 4: {
			List<MmochatEquipAttributeType> list = MmochatPkMachineService
					.getPkStoneBaseAttrList();
			title = "如何镶嵌武魂技能";
			content = "武魂要想获得技能，必须镶嵌武魂石，武魂石会在战神、BOSS及各类活动怪中机率掉落。武魂石基础类型有";
			for (MmochatEquipAttributeType attrType : list) {
				content += attrType.toString() + "、";
			}
			content += "一个武魂上镶嵌的所有武魂石，要求其基础类型必须一致!如基础类型全部是敏捷的武魂石，"
					+ "可以镶嵌到一个武魂上，这个武魂就不能再镶嵌基础类型为力量的武魂石。"
					+ "在本NPC处进行<武魂技能镶嵌>操作，即可将一定数量的武魂石合到武魂上。";
			break;
		}
		case 5: {
			title = "武魂石技能";
			content = MmochatUtil.wrapColor("所有可能的技能(满级效果)\n\n", Color.yellow);
			List<MmochatEquipAttributeType> list = MmochatPkMachineService
					.getPkStoneAttrList();
			int index = 1;
			for (MmochatEquipAttributeType attrType : list) {
				int skillValue = MmochatPkMachineService
						.getPkStoneSkillValueByLevel(attrType,
								MmochatConstant.pkStoneMaxLevel);
				content += MmochatUtil.wrapColor(index + "、"
						+ attrType.getStartInfo() + "+" + skillValue
						+ attrType.getEndInfo() + "\n\n", Color.green);
				index++;
			}
			break;
		}
		case 6: {
			title = "武魂石如何升级";
			content = "武魂石灵气达到升级要求时，就会升级。在活动怪中会掉落武魂石灵气丹，"
					+ "商城中出售的武魂石灵气池，都可以提升武魂石的灵气。要提升武魂石灵气，须在本"
					+ "NPC处点击<武魂石升级>功能进行操作。武魂石升到特定等级，附带的技能数值就会得到提升。";
			break;
		}
		case 7: {
			title = "武魂石等级上限";
			content = "武魂石鉴定后，初始等级上限为" + MmochatConstant.pkStoneInitLevelLimit
					+ "级，当武魂石达到此等级后，将不能继续升级。但等级上限也是可以提升的，在本NPC处进行"
					+ "<武魂石等级上限突破>操作，最高可将等级上限提高到"
					+ MmochatConstant.pkStoneMaxLevel
					+ "级。具体操作要求可参看<武魂石等级上限突破>的改造说明。";
			break;
		}
		case 8: {
			title = "武魂技能分离";
			content = "武魂石镶嵌到武魂后，可以在本NPC处很方便得重新将武魂石拆离出来，武魂石的等级、灵气、"
					+ "技能等都不会发生变化。所以可以很方便得从这个武魂拆到另一个武魂上。"
					+ "这也是武魂作为一个容器型法宝的一个特点。";
			break;
		}
		default:
			break;
		}
		tlv.setTitle(title);
		tlv.setContent(new Text(content));
		return MmochatUtil.tlvResponse(req.getHallState(), tlv);
	}

	// 9.64 威望抽奖
	@SkymobiService
	public SkymobiProtocolMessage handleC_9_64(SkymobiHandler handler,
			Mmochat_9_64C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		int honorToChange = MmochatConstant.honorNumPerRandAward;
		if (me.getHonor() < honorToChange) {
			return MmochatUtil.msgbox(req.getHallState(), "您的威望不足"
					+ honorToChange + "点!");
		}
		if (!me.hasEnoughPackageSpace(1)) {
			return MmochatUtil.msgbox(req.getHallState(), "您的包裹已满,请先清理出一个空位!");
		}
		if (me.isPetFull()) {
			return MmochatUtil.msgbox(req.getHallState(),
					"您携带的宠物数已达上限，无法抽奖。请先整理出一个宠物空间!");
		}
		// 开始兑换
		synchronized (me) {
			if (me.getHonor() < honorToChange) {
				return MmochatUtil.msgbox(req.getHallState(), "您的威望不足"
						+ honorToChange + "点!");
			}
			if (!me.hasEnoughPackageSpace(1)) {
				return MmochatUtil.msgbox(req.getHallState(),
						"您的包裹已满,请先清理出一个空位!");
			}
			if (me.isPetFull()) {
				return MmochatUtil.msgbox(req.getHallState(),
						"您携带的宠物数已达上限，无法抽奖。请先整理出一个宠物空间!");
			}
			me.addHonor(-1 * honorToChange);

			// 每次200威望，相当于20万
			// 白娘子(变异)、1-5星武魂、商城道具、战绩!
			if (MmochatUtil.isInPercent(0.1)) {
				// 白娘子，0.1%机率，平均2亿出一次
				MmochatPet pet = MmochatPetService
						.createPetByType(MmochatRoleType.白娘子);
				if (pet != null) {
					me.addPet(pet);
					try {
						MmochatDao.saveHonorAndPets(me);
					} catch (Exception e) {
						e.printStackTrace();
						me.addHonor(honorToChange);
						me.delPet(pet.getId());
						return MmochatUtil.msgbox(req.getHallState(),
								"服务器忙，请稍候再试!");
					}

					Mmochat_5_10S pack = new Mmochat_5_10S();
					pack.addPet(pet);
					MmochatUtil.sendCommonPack(me, pack);

					String sysInfo = "哇!"
							+ MmochatUtil.wrapColor(me.getName(), Color.green)
							+ "在威望抽奖时喜中大奖，得到一个"
							+ MmochatUtil.wrapColor(pet.getPetTypeName(),
									Color.yellow) + "!朋友们快找他请客呀~";
					sysInfo = MmochatUtil.wrapColor(sysInfo, Color.red);
					MmochatChatService.sendSystemMsg(sysInfo);

					String myInfo = "恭喜恭喜!您喜中大奖，获得一个"
							+ MmochatUtil.wrapColor(pet.getPetTypeName(),
									Color.yellow) + "，快按0键打开宠物信息看看吧!";
					return MmochatUtil.msgbox(req.getHallState(), myInfo);
				}
			} else if (MmochatUtil.isInPercent(10)) {
				// 1-5星武魂，15%机率，平均140万出一个
				MmochatSuperMachine m = MmochatPkMachineService
						.getRandomPkMachine();
				me.addObjectToPackage(m);
				try {
					MmochatDao.saveHonorAndPackage(me);
				} catch (Exception e) {
					e.printStackTrace();
					me.addHonor(honorToChange);
					me.delPackageObjById(m.getId());
					return MmochatUtil
							.msgbox(req.getHallState(), "服务器忙，请稍候再试!");
				}
				return MmochatUtil.msgbox(req.getHallState(), "您抽中了一个武魂!");
			} else if (MmochatUtil.isInPercent(50)) {
				int zhangji = MmochatUtil.getRandomValue(200, 400);
				me.addZhanji(zhangji);
				try {
					MmochatDao.setHonor(me.getHonor(), me.getRoleId());
				} catch (Exception e) {
					e.printStackTrace();
					me.addHonor(honorToChange);
					me.addZhanji(-1 * zhangji);
					return MmochatUtil
							.msgbox(req.getHallState(), "服务器忙，请稍候再试!");
				}
				return MmochatUtil.msgbox(req.getHallState(), "您抽中了" + zhangji
						+ "点战绩!");
			} else {
				// propType->机率
				Object propRate[][] = { { MmochatPropType.传送符, 0.02 },
						{ MmochatPropType.龙涎香, 0.02 },
						{ MmochatPropType.中血池, 0.02 },
						{ MmochatPropType.小血池, 0.03 },
						{ MmochatPropType.中法池, 0.02 },
						{ MmochatPropType.小法池, 0.03 },
						{ MmochatPropType.中血玲珑, 0.02 },
						{ MmochatPropType.小血玲珑, 0.03 },
						{ MmochatPropType.中法玲珑, 0.02 },
						{ MmochatPropType.小法玲珑, 0.03 },
						{ MmochatPropType.混沌石, 0.01 },
						{ MmochatPropType.超级改造石, 0.01 },
						{ MmochatPropType.喇叭, 0.04 },
						{ MmochatPropType.成长丹, 0.02 },
						{ MmochatPropType.超级成长丹, 0.01 },
						{ MmochatPropType.轮回水, 0.05 },
						{ MmochatPropType.迟滞水, 0.02 },
						{ MmochatPropType.八卦令, 0.02 },
						{ MmochatPropType.银联卡, 0.02 },
						{ MmochatPropType.赎罪牌, 0.11 },
						{ MmochatPropType.后悔药, 0.05 },
						{ MmochatPropType.防冻剂, 0.05 },
						{ MmochatPropType.镇定剂, 0.05 },
						{ MmochatPropType.虚无水, 0.05 },
						{ MmochatPropType.武魂石灵气丹, 0.05 },
						{ MmochatPropType.武魂石, 0.2 } };
				double rate = Math.random();
				double curRate = 0;
				for (int i = 0; i < propRate.length; i++) {
					curRate += (Double) propRate[i][1];
					if (curRate > rate) {
						// 命中道具
						MmochatProp newProp = new MmochatProp(
								(MmochatPropType) propRate[i][0]);
						me.addObjectToPackage(newProp);
						try {
							MmochatDao.saveHonorAndPackage(me);
						} catch (Exception e) {
							e.printStackTrace();
						}
						return MmochatUtil.msgbox(req.getHallState(), "您抽中一个"
								+ newProp.getType().toString() + "!");
					}
				}
			}

			return MmochatUtil.msgbox(req.getHallState(), "服务器忙，请稍候再试!");
		}
	}

	// 获取NPC功能列表，相当于直接点击NPC
	public static CtrlTLVStructureRequest getNpcTlv(MmochatPlayer me, int npcId) {
		if (me == null) {
			return null;
		}

		MmochatNpc npc = MmochatNpcService.getNpcById(npcId);
		if (npc == null) {
			return MmochatUtil.msgboxWithoutHallState("目标已经离开!");
		}
		if (npc instanceof MmochatTempNpc) {
			MmochatTempNpc boss = (MmochatTempNpc) npc;
			if (boss.getState() == MmochatNpcState.离开) {
				return MmochatUtil.msgboxWithoutHallState("目标已经离开!");
			} else if (boss.getState() == MmochatNpcState.战斗中) {
				return MmochatUtil.msgboxWithoutHallState("目标正在战斗中,请稍候再来!");
			}
		}

		// 获取所有<可接任务>,<未完成任务>,<可交任务>列表
		List<MmochatTask> canAcceptTasks = new ArrayList<MmochatTask>();
		List<MmochatTask> notFinishTasks = new ArrayList<MmochatTask>();
		List<MmochatTask> canFinishTasks = new ArrayList<MmochatTask>();
		for (MmochatTask task : npc.getTasks().values()) {
			if (task.getAccept_npcId() == npc.getNpcId()
					&& me.canAcceptTask(task.getTaskId())) {
				canAcceptTasks.add(task);
			} else if (task.getFinish_npcId() == npc.getNpcId()) {
				if (me.canFinishTask(task.getTaskId())) {
					// 可交付的任务(如果需要完成一场战斗，也认为是可交付)
					canFinishTasks.add(task);
				} else if (me.isNotFinishTask(task.getTaskId())) {
					notFinishTasks.add(task);
				}
			}
		}

		if (canAcceptTasks.size() == 0 && canFinishTasks.size() == 0
				&& notFinishTasks.size() == 0
				&& npc.getFunctionItems().size() == 0) {
			// 默认对话
			CreateMsgBoxTLVWithBmp msgbox = new CreateMsgBoxTLVWithBmp();
			msgbox.setContent(new Text(npc.getDefaultMessage()));
			msgbox.setLeftName("确定");
			msgbox.setBmpId(npc.getBmpType().getValue());
			return MmochatUtil.tlvResponseWithoutHallState(msgbox);
		} else {
			// 可接,未完成任务,可交任务列表
			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinId(MmochatConstant.TLV_WIN_TASKLIST);
			tlv.setWinType(WinType.List);
			tlv.setLeftName("确定");
			tlv.setRightName("返回");
			tlv.setTitle(npc.getName());
			tlv.setWinHeight(188);
			tlv.addRightTLV(new CloseWinTLV(MmochatConstant.TLV_WIN_TASKLIST));

			for (MmochatTask task : canFinishTasks) {
				tlv.addItemEvent(MmochatUtil.wrapColor(task.getTaskName()
						+ "(可交付)", Color.yellow), new ClearDataTLV(),
						new AddDataTLV(task.getTaskId()), new AddDataTLV(
								(int) npc.getNpcId()), new SendDataTLV(
								MmochatConstant.getClientModuleId(),
								MmochatMain.getModuleInstID(),
								MmochatConstant.MSGCODE_MMOCHAT_C_4_2, (int) me
										.getRoleId()));
			}
			for (MmochatTask task : canAcceptTasks) {
				tlv.addItemEvent(MmochatUtil.wrapColor(task.getTaskName(),
						Color.yellow), new ClearDataTLV(), new AddDataTLV(
						(int) task.getTaskId()), new AddDataTLV((int) npc
						.getNpcId()), new SendDataTLV(MmochatConstant
						.getClientModuleId(), MmochatMain.getModuleInstID(),
						MmochatConstant.MSGCODE_MMOCHAT_C_4_2, (int) me
								.getRoleId()));
			}
			for (MmochatTask task : notFinishTasks) {
				tlv.addItemEvent(MmochatUtil.wrapColor(task.getTaskName()
						+ "(未完成)", Color.yellow), new ClearDataTLV(),
						new AddDataTLV(task.getTaskId()), new AddDataTLV(
								(int) npc.getNpcId()), new SendDataTLV(
								MmochatConstant.getClientModuleId(),
								MmochatMain.getModuleInstID(),
								MmochatConstant.MSGCODE_MMOCHAT_C_4_2, (int) me
										.getRoleId()));
			}

			// NPC固定功能
			for (MmochatNpcItemType function : npc.getFunctionItems()) {
				tlv.addItemEvent(function.toString(), new ClearDataTLV(),
						new AddDataTLV((int) npc.getNpcId()), new AddDataTLV(
								(int) function.getValue()), new SendDataTLV(
								MmochatConstant.getClientModuleId(),
								MmochatMain.getModuleInstID(),
								MmochatConstant.MSGCODE_MMOCHAT_C_9_1, (int) me
										.getRoleId()));
			}
			tlv.addLeftTLV(new ShowWaitingMsgBoxTLV());
			return MmochatUtil.tlvResponseWithoutHallState(tlv);
		}
	}

	public static TLVStructure getNpcTlvWin(MmochatPlayer me, int npcId) {
		if (me == null) {
			return null;
		}

		MmochatNpc npc = MmochatNpcService.getNpcById(npcId);
		if (npc == null) {
			return null;
		}
		if (npc instanceof MmochatTempNpc) {
			MmochatTempNpc boss = (MmochatTempNpc) npc;
			if (boss.getState() == MmochatNpcState.离开) {
				return null;
			} else if (boss.getState() == MmochatNpcState.战斗中) {
				return null;
			}
		}

		// 获取所有<可接任务>,<未完成任务>,<可交任务>列表
		List<MmochatTask> canAcceptTasks = new ArrayList<MmochatTask>();
		List<MmochatTask> notFinishTasks = new ArrayList<MmochatTask>();
		List<MmochatTask> canFinishTasks = new ArrayList<MmochatTask>();
		for (MmochatTask task : npc.getTasks().values()) {
			if (task.getAccept_npcId() == npc.getNpcId()
					&& me.canAcceptTask(task.getTaskId())) {
				canAcceptTasks.add(task);
			} else if (task.getFinish_npcId() == npc.getNpcId()) {
				if (me.canFinishTask(task.getTaskId())) {
					// 可交付的任务(如果需要完成一场战斗，也认为是可交付)
					canFinishTasks.add(task);
				} else if (me.isNotFinishTask(task.getTaskId())) {
					notFinishTasks.add(task);
				}
			}
		}

		if (canAcceptTasks.size() == 0 && canFinishTasks.size() == 0
				&& notFinishTasks.size() == 0
				&& npc.getFunctionItems().size() == 0) {
			// 默认对话
			CreateMsgBoxTLVWithBmp msgbox = new CreateMsgBoxTLVWithBmp();
			msgbox.setContent(new Text(npc.getDefaultMessage()));
			msgbox.setLeftName("确定");
			msgbox.setBmpId(npc.getBmpType().getValue());
			return msgbox;
		} else {
			// 可接,未完成任务,可交任务列表
			CreateTlvWin tlv = new CreateTlvWin();
			tlv.setWinId(MmochatConstant.TLV_WIN_TASKLIST);
			tlv.setWinType(WinType.List);
			tlv.setLeftName("确定");
			tlv.setRightName("返回");
			tlv.setTitle(npc.getName());
			tlv.setWinHeight(188);
			tlv.addRightTLV(new CloseWinTLV(MmochatConstant.TLV_WIN_TASKLIST));

			for (MmochatTask task : canFinishTasks) {
				tlv.addItemEvent(MmochatUtil.wrapColor(task.getTaskName()
						+ "(可交付)", Color.yellow), new ClearDataTLV(),
						new AddDataTLV(task.getTaskId()), new AddDataTLV(
								(int) npc.getNpcId()), new SendDataTLV(
								MmochatConstant.getClientModuleId(),
								MmochatMain.getModuleInstID(),
								MmochatConstant.MSGCODE_MMOCHAT_C_4_2, (int) me
										.getRoleId()));
			}
			for (MmochatTask task : canAcceptTasks) {
				tlv.addItemEvent(MmochatUtil.wrapColor(task.getTaskName(),
						Color.yellow), new ClearDataTLV(), new AddDataTLV(
						(int) task.getTaskId()), new AddDataTLV((int) npc
						.getNpcId()), new SendDataTLV(MmochatConstant
						.getClientModuleId(), MmochatMain.getModuleInstID(),
						MmochatConstant.MSGCODE_MMOCHAT_C_4_2, (int) me
								.getRoleId()));
			}
			for (MmochatTask task : notFinishTasks) {
				tlv.addItemEvent(MmochatUtil.wrapColor(task.getTaskName()
						+ "(未完成)", Color.yellow), new ClearDataTLV(),
						new AddDataTLV(task.getTaskId()), new AddDataTLV(
								(int) npc.getNpcId()), new SendDataTLV(
								MmochatConstant.getClientModuleId(),
								MmochatMain.getModuleInstID(),
								MmochatConstant.MSGCODE_MMOCHAT_C_4_2, (int) me
										.getRoleId()));
			}

			// NPC固定功能
			for (MmochatNpcItemType function : npc.getFunctionItems()) {
				tlv.addItemEvent(function.toString(), new ClearDataTLV(),
						new AddDataTLV((int) npc.getNpcId()), new AddDataTLV(
								(int) function.getValue()), new SendDataTLV(
								MmochatConstant.getClientModuleId(),
								MmochatMain.getModuleInstID(),
								MmochatConstant.MSGCODE_MMOCHAT_C_9_1, (int) me
										.getRoleId()));
			}
			tlv.addLeftTLV(new ShowWaitingMsgBoxTLV());
			return tlv;
		}
	}

	// 设置跨服王者宣言
	@SuppressWarnings("deprecation")
	@SkymobiService
	public SkymobiProtocolMessage handleC_9_65(SkymobiHandler handler,
			Mmochat_9_65C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		// 判定是否为试道王者
		boolean hasChenhao = false;
		for (MmochatChenHao chenhao : me.getChenHaoMap().values()) {
			if (chenhao.getType() == MmochatChenHaoType.跨服王者
					&& !chenhao.isTimeOut()) {
				hasChenhao = true;
				break;
			}
		}
		if (!hasChenhao) {
			return MmochatUtil.msgbox(req.getHallState(),
					"只有拥有跨服王者称号的玩家，才能设置跨服王者宣言!");
		}
		// 判定日期
		long deadTime = 0;
		Date now = new Date();
		if (now.getDay() == 4 || now.getDay() == 5) {
			// 周四周五可以设置
			now.setHours(23);
			now.setMinutes(59);
			now.setSeconds(59);
			deadTime = now.getTime();

			if (now.getDay() == 4) {
				deadTime += MmochatConstant.MS_PER_DAY;
			}
		} else {
			return MmochatUtil.msgbox(req.getHallState(), "只有周四、周五才允许设置跨服宣言。");
		}

		String userMsg = req.getInfo();
		if (userMsg == null || userMsg.length() == 0) {
			return MmochatUtil.msgbox(req.getHallState(), "宣言内容不能为空!");
		}
		if (userMsg.contains("") || userMsg.contains("")
				|| userMsg.contains("") || userMsg.contains("")) {
			return MmochatUtil.msgbox(req.getHallState(), "您的宣言内容中包含不可见字符!");
		}
		if (userMsg.length() > 20) {
			return MmochatUtil.msgbox(req.getHallState(), "宣言内容不能超过20个字!");
		}
		
		// 判定发送间隔
		Long lastTime = mixWuDaoWordsUpdateTimes.get(me.getRoleId());
		if (lastTime != null) {
			if (System.currentTimeMillis() - lastTime < MmochatConstant.MS_PER_HOUR) {
				return MmochatUtil.msgbox(req.getHallState(),
						"每小时可以更新一次跨服宣言，您距上次更新还不足1小时!");
			}
		}
		mixWuDaoWordsUpdateTimes
				.put(me.getRoleId(), System.currentTimeMillis());

		String msg = MmochatFilterService.getFilterString(userMsg);
		int range = me.getLevel() / 10 * 10;	
		
		// 将消息发送到列表服务器，再由列表服务器分发到所有服务器
		synchronized (multiServerPkNpcLock) {
			Mmochat_SetMixWuDaoWordsToServerList pack = new Mmochat_SetMixWuDaoWordsToServerList(
					MmochatMain.pkServerInstID);			
			pack.setRoleId(me.getRoleId());			
			pack.setSrcInstId(MmochatMain.moduleInstID);
			pack.setName(me.getName());
			pack.setWords(msg);
			pack.setLevelRange(range);			

			// 申请进入跨服战服务器
			MmochatUtil.sendMultiServerPack(pack);

			// 控制发送频率
			try {
				Thread.sleep(100);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
		
		return MmochatUtil.msgbox(req.getHallState(), "设置成功!"
				+ MmochatUtil.wrapColor("所有区服" + range + "级别段", Color.yellow)
				+ "的玩家的登陆公告中，将会出现您的宣言内容!");
	}

	// 设置试道王者宣言
	@SuppressWarnings("deprecation")
	@SkymobiService
	public SkymobiProtocolMessage handleC_9_66(SkymobiHandler handler,
			Mmochat_9_66C req) {
		MmochatPlayer me = MmochatMainService.getPlayerByRoleId(req, req
				.getRoleId());
		if (me == null) {
			return MmochatUtil.msgbox(req.getHallState(), "服务器忙,请稍候再试!");
		}
		// 判定是否为试道王者
		boolean hasChenhao = false;
		for (MmochatChenHao chenhao : me.getChenHaoMap().values()) {
			if (chenhao.getType() == MmochatChenHaoType.试道王者
					&& !chenhao.isTimeOut()) {
				hasChenhao = true;
				break;
			}
		}
		if (!hasChenhao) {
			return MmochatUtil.msgbox(req.getHallState(),
					"只有拥有试道王者称号的玩家，才能设置试道王者宣言!");
		}
		// 判定日期
		long deadTime = 0;
		Date now = new Date();
		if (now.getDay() == 1 || now.getDay() == 2) {
			// 周一周二可以设置
			now.setHours(23);
			now.setMinutes(59);
			now.setSeconds(59);
			deadTime = now.getTime();

			if (now.getDay() == 1) {
				deadTime += MmochatConstant.MS_PER_DAY;
			}
		} else {
			return MmochatUtil.msgbox(req.getHallState(), "只有周一、周二才允许设置宣言。");
		}

		String userMsg = req.getInfo();
		if (userMsg == null || userMsg.length() == 0) {
			return MmochatUtil.msgbox(req.getHallState(), "宣言内容不能为空!");
		}
		if (userMsg.contains("") || userMsg.contains("")
				|| userMsg.contains("") || userMsg.contains("")) {
			return MmochatUtil.msgbox(req.getHallState(), "您的宣言内容中包含不可见字符!");
		}
		if (userMsg.length() > 20) {
			return MmochatUtil.msgbox(req.getHallState(), "宣言内容不能超过20个字!");
		}
		String msg = MmochatFilterService.getFilterString(userMsg);

		int range = me.getLevel() / 10 * 10;
		MmochatWuDaoWinWords words = new MmochatWuDaoWinWords();
		words.setRoleId(me.getRoleId());
		words.setName(me.getName());
		words.setWords(msg);
		words.setLevelRange(range);
		words.setDeadTime(deadTime);
		wuDaoWinWords.put(me.getRoleId(), words);

		return MmochatUtil.msgbox(req.getHallState(), "设置成功!本区所有" + range
				+ "级别段的玩家的登陆公告中，将会出现您的宣言内容!");
	}
}
